summaryrefslogtreecommitdiff
path: root/flash/bootloader/bootloader.h
diff options
context:
space:
mode:
Diffstat (limited to 'flash/bootloader/bootloader.h')
-rw-r--r--flash/bootloader/bootloader.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/flash/bootloader/bootloader.h b/flash/bootloader/bootloader.h
new file mode 100644
index 0000000000..eee61c4809
--- /dev/null
+++ b/flash/bootloader/bootloader.h
@@ -0,0 +1,111 @@
1#ifndef NULL
2#define NULL ((void*)0)
3#endif
4
5#define TRUE 1
6#define FALSE 0
7
8// scalar types
9typedef unsigned char UINT8;
10typedef unsigned short UINT16;
11typedef unsigned long UINT32;
12typedef int BOOL;
13
14typedef void(*tpFunc)(void); // type for execute
15typedef int(*tpMain)(void); // type for start vector to main()
16
17
18// structure of an image in the flash
19typedef struct
20{
21 UINT32* pDestination; // address to copy it to
22 UINT32 size; // how many bytes of payload (to the next header)
23 tpFunc pExecute; // entry point
24 UINT32 flags; // uncompressed or compressed
25 // end of header, now comes the payload
26 UINT32 image[]; // the binary image starts here
27 // after the payload, the next header may follow, all 0xFF if none
28} tImage;
29
30// flags valid for image header
31#define IF_NONE 0x00000000
32#define IF_UCL_2E 0x00000001 // image is compressed with UCL, algorithm 2e
33
34
35// resolve platform dependency of F1 button check
36#if defined PLATFORM_PLAYER
37#define CHANNEL 1
38#define F1_LOWER 0 // this is the "Menu" key
39#define F1_UPPER 384
40#define F2_LOWER 1024 // not present
41#define F2_UPPER 1024
42#define F3_LOWER 1024
43#define F3_UPPER 1024
44#elif defined PLATFORM_RECORDER
45#define CHANNEL 4
46#define F1_LOWER 250
47#define F1_UPPER 499
48#define F2_LOWER 500
49#define F2_UPPER 699
50#define F3_LOWER 900
51#define F3_UPPER 1023
52#elif defined PLATFORM_FM
53#define CHANNEL 4
54#define F1_LOWER 150
55#define F1_UPPER 384
56#define F2_LOWER 385
57#define F2_UPPER 544
58#define F3_LOWER 700
59#define F3_UPPER 1023
60#else
61#error ("No platform given!")
62#endif
63
64#define FLASH_BASE 0x02000000 // start of the flash memory
65#define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version
66
67
68// prototypes
69void _main(void) __attribute__ ((section (".startup")));
70int main(void);
71void PlatformInit(void);
72void DramInit(void);
73int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len);
74void DecompressStart(tImage* pImage);
75int ReadADC(int channel);
76int ButtonPressed(void);
77tImage* GetStartImage(int nPreferred);
78// test functions
79void SetLed(BOOL bOn);
80void UartInit(void);
81UINT8 UartRead(void);
82void UartWrite(UINT8 byte);
83void MiniMon(void);
84
85
86// minimon commands
87#define BAUDRATE 0x00 // followed by BRR value; response: command byte
88#define ADDRESS 0x01 // followed by 4 bytes address; response: command byte
89#define BYTE_READ 0x02 // response: 1 byte content
90#define BYTE_WRITE 0x03 // followed by 1 byte content; response: command byte
91#define BYTE_READ16 0x04 // response: 16 bytes content
92#define BYTE_WRITE16 0x05 // followed by 16 bytes; response: command byte
93#define BYTE_FLASH 0x06 // followed by 1 byte content; response: command byte
94#define BYTE_FLASH16 0x07 // followed by 16 bytes; response: command byte
95#define HALFWORD_READ 0x08 // response: 2 byte content
96#define HALFWORD_WRITE 0x09 // followed by 2 byte content; response: command byte
97#define EXECUTE 0x0A // response: command byte if call returns
98#define VERSION 0x0B // response: version
99
100
101// linker symbols
102extern UINT32 begin_text[];
103extern UINT32 end_text[];
104extern UINT32 begin_data[];
105extern UINT32 end_data[];
106extern UINT32 begin_bss[];
107extern UINT32 end_bss[];
108extern UINT32 begin_stack[];
109extern UINT32 end_stack[];
110extern UINT32 begin_iramcopy[];
111extern UINT32 total_size[];