forked from urjaman/fernly
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstage1.c
41 lines (31 loc) · 785 Bytes
/
stage1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <string.h>
#include "bionic.h"
#include "memio.h"
#include "printf.h"
#include "serial.h"
#include "utils.h"
#include "fernvale-pmic.h"
char welcome_banner1[] = "Fernly stage 1 loader for 6261\r\n";
char welcome_banner2[] = "Write four bytes of program size, then write program data...\r\n>";
#define LOADADDR 0x70000000
// for osmocom gen'd firmware use 0x40000000
//#define LOADADDR 0x40000000
int main()
{
uint32_t i;
uint32_t psize;
uint8_t *p;
void (*jumpaddr)(void);
serial_init();
serial_puts(welcome_banner1);
serial_puts(welcome_banner2);
p = (uint8_t *) &psize;
for (i=0; i<4; ++i)
p[i] = serial_getc();
p = (uint8_t *) LOADADDR;
for (i=0; i<psize; ++i)
p[i] = serial_getc();
jumpaddr = (void (*)(void)) LOADADDR;
jumpaddr();
return 0;
}