Project

General

Profile

Download (3.34 KB) Statistics
| Branch: | Tag: | Revision:
1
- data that is needed from both app and dfu mode
2
- code that is needed from both app and dfu mode
3
	- function pointers
4
	- copy code to RAM in case of DFU switch
5
- data that is only needed in DFU mode
6
	- can be overwritten in case of reset-to-application
7
- data that is only needed in app mode
8
	- can be overwritten with DFU data in case of DFU switch
9
- code that is only needed in DFU mode
10
	- has to be copied to ram in case of DFU switch
11
- code that is only needed in app mode
12
	- can be read from flash, no action required
13

    
14

    
15
=> abandoned that complicated idea.  
16
now all DFU functions are __ramfunc's and thus always present.
17

    
18

    
19
interaction between app and dfu code:
20

    
21
- dfu_switch(void)
22
- dfu_status (can be put in accessor function, if required)
23
- dfu_cfg_descriptor
24
- dfu_dev_descriptor
25
- dfu_ep0_handler()
26

    
27

    
28
order of events at boot;
29

    
30
- start at reset vector in flash
31
	- AT91F_LowLevelInit()
32
- setup stack for each mode
33
- relocate 'data' of bootloader, including ramfunc/vectram
34
- clear 'bss' of bootloader
35
- call remap command
36
	- call usb initialization (irq, clock)
37
	- if keypress,
38
		- call dfu_main()
39
			- wait for ep0 / busreset interrupt
40
	- else call main()
41

    
42

    
43
memory layout:
44

    
45
0: lowlevel startup code
46
	Cstartup.o	0x00bc
47
	Cstartup_SAM7.o	0x0100
48
	dfufunc		0x1dcc
49
	dfustruct	0x0038
50

    
51
	text		text	0x0070
52
data		data	0x0000
53
bss		bss	0x000c
54

    
55
flash 	= text + data  (= 8k)
56
ram/rel	= data + bss (12 bytes)
57

    
58

    
59
If we drop the DFU-can-flash-DFU requirement, we can leave all DFU related code
60
in flash. no need for  any function to be permanently in RAM.  However, not
61
preventing this feature in some future version, we shouldn't do that.
62

    
63

    
64
Function			DFU	runtime
65
udp_init			x	x	RAM
66
udp_ep0_send_data		x	x	RAM
67
udp_ep0_send_zlp		x	x	RAM
68
udp_sp0_send_stall		x	x	RAM
69
handle_dnload			x	-	flash/relocated
70
handle_upload			x	-	flash/relocated
71
handle_getstatus		x	-	flash/relocated
72
handle_getstate			x	-	flash/relocated
73
dfu_ep0_handler			x	x	RAM
74

    
75
dfu_dev_descriptor		x	-	flash/relocated
76
dfu_cfg_descriptor		x	-	flash/relocated
77
dfu_udp_ep0_handler		x	-	flash/relocated
78
dfu_udp_irq			x	-	flash/relocated
79
dfu_switch			-	x	RAM
80
dfu_main			x	-	flash/relocated
81
vectram				x	x	flash/relocated/switched
82
IRQ_Handler_EntryR		x	x	flash/relocated/switched
83
_remap				x	-	flash/reloaded
84

    
85
dfu_api				x	x	flash (const anyway)
86
dfu_state			x	x	RAM
87

    
88

    
89
preconditions:
90
	- dfu code assumes to be loaded to address zero to make it work from both ram and rom
91

    
92
startup:
93
	- exception vectors (in flash)
94
	- call lowlevel_init
95
	- setup user/supervisor/FIQ/IRQ stack
96
	- relocate dfu_state
97
	- if DFU switch is pressed
98
		- jump to dfu_main in flash
99
			- relocate all of DFU .text/.data into ram (including exception vectors)
100
			- initialize DFU .bss
101
			- remap RAM to address zero
102

    
103
	- if DFU switch is not pressed jump to entry address of app
104
		- Cstartup_app.S
105
			- relocate application .data
106
			- initialize application .bss
107
			- jump to appliction main 
108
			- application uses dfu_api in flash, pointing to in-flash data
109
			- application calls dfu_switch()
110
				- disable all interupts but USB
111
				- relocate all of DFU .text/.data into ram (including exception vectors)
112
				- remap RAM to address zero
113
				- check whether app has already remapped RAM before !?!
114

    
115
memory map:
116

    
117
load_addr	run_Addr
118
0x00100000	0x00000000	exception vectors (DFU Cstartup)
119
				Cstartup_SAM7
120

    
121
		0x00200000	
122

    
123

    
124
DFU constants:
125
_etext:
126
_data:	0x200000
127
_edata:
128

    
129
APP contants:
130
_data: _edata_dfu
131

    
(1-1/3)
Add picture from clipboard (Maximum size: 48.8 MB)