|
|
(8 intermediate revisions by 5 users not shown) |
Line 1: |
Line 1: |
− | [http://people.msoe.edu/~millerni/forums.php?show=topic&id=150&forum=13 ultram online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=201 free free ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=103&forum=13 free funny ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=194 cheap diethylpropion] [http://wc1.worldcrossing.com/WebX/.1de609fe free qwest ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=207 real ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=186 lipitor online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=149&forum=13 ultracet online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=148&forum=13 tramadol online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=159 cialis online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=142&forum=13 free sony ericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=203 funny ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a32 zoloft] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=120&forum=13 free music ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=336 carisoprodol online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=160&forum=13 cheap zanaflex] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=354 free nokia ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=113&forum=13 cheap lortab] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=362 free motorola ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=209 free samsung ringtones] [http://wc1.worldcrossing.com/WebX/.1de609dd free alltel ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=222 sharp ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a28 cheap soma] [http://wc1.worldcrossing.com/WebX/.1de60a1a free mtv ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=109&forum=13 cheap levitra] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=127&forum=13 pharmacy online online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=361 real ringtones] [http://wc1.worldcrossing.com/WebX/.1de609df ambien online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=98&forum=13 cheap diethylpropion] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=158&forum=13 cheap xanax] [http://news.engin.brown.edu/forums/thread-view.asp?tid=172 lorazepam online] [http://wc1.worldcrossing.com/WebX/.1de609ff real ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=220 punk ringtones] [http://wc1.worldcrossing.com/WebX/.1de609dc albuterol online] [http://wc1.worldcrossing.com/WebX/.1de60a2e xanax online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=156 fioricet] [http://wc1.worldcrossing.com/WebX/.1de60a10 didrex online] [http://wc1.worldcrossing.com/WebX/.1de60a35 free verizon ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=176 ultracet online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=356 tracfone ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=92&forum=13 cheap clomid] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=344 ativan] [http://news.engin.brown.edu/forums/thread-view.asp?tid=155 buy xanax] [http://news.engin.brown.edu/forums/thread-view.asp?tid=178 nexium online] [http://wc1.worldcrossing.com/WebX/.1de60a04 sonyericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=182 cheap clomid] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=82&forum=13 cheap adipex] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=343 cialis] [http://news.engin.brown.edu/forums/thread-view.asp?tid=170 hydrocodone online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=169 cheap levitra] [http://wc1.worldcrossing.com/WebX/.1de609f3 midi ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=111&forum=13 order lisinopril] [http://news.engin.brown.edu/forums/thread-view.asp?tid=224 wwe ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=153 cheap phentermine] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=147&forum=13 tracfone ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=181 cheap sildenafil] [http://news.engin.brown.edu/forums/thread-view.asp?tid=212 free verizon ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=223 midi ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=335 buy phentermine] [http://wc1.worldcrossing.com/WebX/.1de60a00 cheap rivotril] [http://wc1.worldcrossing.com/WebX/.1de60a0a vicodin] [http://news.engin.brown.edu/forums/thread-view.asp?tid=187 cheap celexa] [http://wc1.worldcrossing.com/WebX/.1de609eb free funny ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=197 flexeril online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=105&forum=13 hoodia online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=188 tenuate online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=180 prozac online] [http://wc1.worldcrossing.com/WebX/.1de60a05 free sprint ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f9 norco online] [http://wc1.worldcrossing.com/WebX/.1de609f2 meridia] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=145&forum=13 sprint ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=96&forum=13 diazepam online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=338 online fioricet] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=358 mp3 ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a21 buy paxil] [http://wc1.worldcrossing.com/WebX/.1de60a31 zanaflex online] [http://wc1.worldcrossing.com/WebX/.1de609de but alprazolam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=141&forum=13 soma online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=342 order diazepam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=157&forum=13 free wwe ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=161&forum=13 but zoloft] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=112&forum=13 lorazepam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=124&forum=13 norco] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=355 free ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=88&forum=13 carisoprodol online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=360 qwest ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=167 cheap clonazepam] [http://wc1.worldcrossing.com/WebX/.1de60a0e celexa online] [http://wc1.worldcrossing.com/WebX/.1de609e4 clonazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a17 lipitor online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=123&forum=13 free nokia ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=184 cheap lisinopril] [http://wc1.worldcrossing.com/WebX/.1de60a24 cheap propecia] [http://wc1.worldcrossing.com/WebX/.1de609f8 free nokia ringtones] [http://wc1.worldcrossing.com/WebX/.1de609fd punk ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=154 buy carisoprodol] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=339 cheap ultram] [http://wc1.worldcrossing.com/WebX/.1de60a34 free sony ericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=202 free tracfone ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=199 zyban online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=198 cheap hoodia] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=332 order tramadol] [http://wc1.worldcrossing.com/WebX/.1de60a1d free cingular ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=107&forum=13 jazz ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=219 alltel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=101&forum=13 but flexeril] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=359 nextel ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a15 free kyocera ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=363 free samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=117&forum=13 motorola ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=346 meridia online] [http://wc1.worldcrossing.com/WebX/.1de60a30 cheap xenical] [http://wc1.worldcrossing.com/WebX/.1de60a03 free sony ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=168 cheap paxil] [http://wc1.worldcrossing.com/WebX/.1de60a01 free sagem ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=160 buy ativan] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=136&forum=13 cheap rivotril] [http://wc1.worldcrossing.com/WebX/.1de609fb ortho online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=89&forum=13 celexa online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=139&forum=13 free sharp ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=163 adipex online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=125&forum=13 cheap ortho] [http://wc1.worldcrossing.com/WebX/.1de609ee but hydrocodone] [http://news.engin.brown.edu/forums/thread-view.asp?tid=177 propecia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=91&forum=13 free cingular ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f7 free nextel ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=215 free sagem ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=347 online adipex] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=132&forum=13 punk ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=97&forum=13 buy didrex] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=144&forum=13 free sonyericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=179 didrex online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=158 cheap diazepam] [http://wc1.worldcrossing.com/WebX/.1de60a25 free samsung ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a26 free sharp ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=162 meridia online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=217 free mono ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=152 cheap valium] [http://wc1.worldcrossing.com/WebX/.1de609ec hgh online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=205 nextel ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=357 funny ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=191 cheap lortab] [http://wc1.worldcrossing.com/WebX/.1de60a2b cheap ultracet] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=153&forum=13 buy viagra] [http://news.engin.brown.edu/forums/thread-view.asp?tid=183 albuterol] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=349 cheap vicodin] [http://wc1.worldcrossing.com/WebX/.1de60a18 free motorola ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f0 lorazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a12 free ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a19 mp3 ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=216 free sonyericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=161 cheap viagra] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=95&forum=13 cyclobenzaprine online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=192 but vigrx] [http://wc1.worldcrossing.com/WebX/.1de60a0d wwe ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=185 zoloft online] [http://wc1.worldcrossing.com/WebX/.1de609e3 cheap clomid] [http://wc1.worldcrossing.com/WebX/.1de60a13 order fioricet] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=138&forum=13 free samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=83&forum=13 albuterol online] [http://wc1.worldcrossing.com/WebX/.1de60a29 tramadol online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=173 order xenical] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=350 alprazolam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=93&forum=13 clonazepam online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=204 free mp3 ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=164 cheap norco] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=337 xanax online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=119&forum=13 free mtv ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=206 qwest ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=151&forum=13 valium] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=140&forum=13 cheap sildenafil] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=162&forum=13 cheap zyban] [http://news.engin.brown.edu/forums/thread-view.asp?tid=166 alprazolam online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=353 levitra online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=333 cheap soma] [http://news.engin.brown.edu/forums/thread-view.asp?tid=189 ortho online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=159&forum=13 cheap xenical] [http://wc1.worldcrossing.com/WebX/.1de60a36 cheap zyban] [http://wc1.worldcrossing.com/WebX/.1de60a23 free polyphonic ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=208 motorola ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a1f cheap lisinopril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=137&forum=13 sagem ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a1b free music ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e0 cheap ativan] [http://news.engin.brown.edu/forums/thread-view.asp?tid=229 free jazz ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e5 cool ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=99&forum=13 free ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a07 free tracfone ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=348 but norco] [http://wc1.worldcrossing.com/WebX/.1de60a09 cheap viagra] [http://news.engin.brown.edu/forums/thread-view.asp?tid=218 sony ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=121&forum=13 nexium online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=126&forum=13 cheap paxil] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=94&forum=13 cool ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=154&forum=13 vicodin online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=108&forum=13 free kyocera ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a14 jazz ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=210 free sprint ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0f cialis online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=175 cyclobenzaprine online] [http://people.msoe.edu/~millerni/forums.php?show=topic
| + | == Overview == |
| + | |
| + | [[Image:Dserial-flash-map.png|DSerial Flash Memory Map]] |
| + | |
| + | [[DSerial]] bootloader is the program that is the first to run once the [[C8051F320]] microcontroller is powered. It responds to commands from DS on the SPI port and allows to boot DSerial [[firmware]] amongst other things. |
| + | |
| + | == Description == |
| + | |
| + | The purpose of DSerial bootloader is to: |
| + | * Boot DSerial [[firmware]] |
| + | * Write [[firmware]] to internal flash via SPI (other ports may be supported by the bootloader in the future) |
| + | * Read internal flash |
| + | * Send and receive [[UART]] data without booting into firmware (baud rate fixed at 115200 bps) |
| + | |
| + | The following sections will describe how the bootloader functions. |
| + | |
| + | == Files == |
| + | |
| + | Go to [[downloads]] to get the bootloader source code. |
| + | |
| + | == Detecting DSerial == |
| + | |
| + | Check whether DSerial is inserted using a [http://www.st.com/stonline/books/pdf/docs/10823.pdf SPI Flash] compatible command: |
| + | |
| + | # DS sends the byte 0x9F (RDID) |
| + | # DSerial responds with 0x01 0xAB |
| + | |
| + | |
| + | This is command is non-destructive to DS game cards. See also DSerial [[protocol]]. |
| + | |
| + | == Interrupt Vector Table (Currently Used Method) == |
| + | |
| + | Interrupt vector table on the [[C8051F320]] is always at offset 0 in FLASH. Unfortunately, we cannot re-target it from bootloader interrupt vector table into the program interrupt vector table with a magic register, since no such register exists in the architecture. Instead, we have to re-target each interrupt separately. |
| + | |
| + | The User Bit in [[Registers|PSW register]] (also called F1) is used to select bootloader table or firmware table. |
| + | |
| + | <cpp> |
| + | // Code in bootloader, interrupt.h |
| + | |
| + | /* UART0 interrupt */ |
| + | void redirS0() __interrupt (4) _naked { |
| + | _asm |
| + | push psw |
| + | jnb psw.1, 00001$ ; if user bit not set, jump to firmware irq |
| + | |
| + | pop psw |
| + | lcall _uartInterrupt ; otherwise jump to bootloader irq |
| + | reti |
| + | |
| + | 00001$: |
| + | pop psw |
| + | ljmp #FIRMWARE_OFFSET IRQ_S0 ; firmware irq |
| + | _endasm; |
| + | } |
| + | |
| + | // repeat for the other irqs |
| + | </cpp> |
| + | |
| + | This code jumps to bootloader interrupt if PSW.1 (also called F1) is set to 1, otherwise it jumps to [[firmware]]. |
| + | |
| + | <cpp> |
| + | // Code in bootloader |
| + | |
| + | void main() { |
| + | // ... |
| + | F1 = 1; // relocate interrupts to bootloader |
| + | EA = 1; // global interrupt enable |
| + | // ... |
| + | } |
| + | </cpp> |
| + | |
| + | <cpp> |
| + | // Code in firmware |
| + | |
| + | void main() { |
| + | // ... |
| + | F1 = 0; // relocate interrupts to FIRMWARE_OFFSET (0x0800) |
| + | EA = 1; // global interrupt enable |
| + | // ... |
| + | } |
| + | </cpp> |
| + | |
| + | == Interrupt Vector Table (Not Used Method) == |
| + | |
| + | The following code shows another way that could have been used. Its advantage is that the interrupt vector can be relocated to any address dynamically. The disadvantage is that there's bigger overhead. |
| + | |
| + | <cpp> |
| + | // Code in bootloader |
| + | |
| + | // Redirects UART IRQ either into our (bootloader's) handler or into firmware handler. |
| + | void R_uartInterrupt() __interrupt (4) _naked { |
| + | _asm |
| + | mov a, _IrqVector ; compare IrqVector to 0 |
| + | jnz 00001$ |
| + | mov a, (_IrqVector 1) |
| + | jz 00002$ |
| + | 00001$: ; if not 0, then we need to jump to it |
| + | mov dpl, _IrqVector |
| + | mov dph, (_IrqVector 1) |
| + | mov a, #0x23 ; this is the offset for uart irq |
| + | jmp @a dptr ; call the interrupt handler in firmware |
| + | 00002$: ; if it's 0, then we'll handle the irq |
| + | lcall _uartInterrupt ; call our own interrupt handler |
| + | reti |
| + | _endasm; |
| + | } |
| + | |
| + | // repeat for the other irqs |
| + | </cpp> |
| + | |
| + | IrqVector is a global variable that is set to the location of interrupt vector before enabling interrupts. The bootloader should set IrqVector to 0 while the program should set it to it's location. |
| + | |
| + | <cpp> |
| + | // Code in firmware |
| + | |
| + | __data __at (0x7e) unsigned int IrqVector; |
| + | |
| + | void main() { |
| + | // ... |
| + | IrqVector = 0x0800; // we're relocated to 0x0800 |
| + | EA = 1; // global interrupt enable |
| + | // ... |
| + | } |
| + | </cpp> |
Latest revision as of 16:25, 14 September 2010
Overview
DSerial bootloader is the program that is the first to run once the C8051F320 microcontroller is powered. It responds to commands from DS on the SPI port and allows to boot DSerial firmware amongst other things.
Description
The purpose of DSerial bootloader is to:
- Boot DSerial firmware
- Write firmware to internal flash via SPI (other ports may be supported by the bootloader in the future)
- Read internal flash
- Send and receive UART data without booting into firmware (baud rate fixed at 115200 bps)
The following sections will describe how the bootloader functions.
Files
Go to downloads to get the bootloader source code.
Detecting DSerial
Check whether DSerial is inserted using a SPI Flash compatible command:
- DS sends the byte 0x9F (RDID)
- DSerial responds with 0x01 0xAB
This is command is non-destructive to DS game cards. See also DSerial protocol.
Interrupt Vector Table (Currently Used Method)
Interrupt vector table on the C8051F320 is always at offset 0 in FLASH. Unfortunately, we cannot re-target it from bootloader interrupt vector table into the program interrupt vector table with a magic register, since no such register exists in the architecture. Instead, we have to re-target each interrupt separately.
The User Bit in PSW register (also called F1) is used to select bootloader table or firmware table.
<cpp>
// Code in bootloader, interrupt.h
/* UART0 interrupt */
void redirS0() __interrupt (4) _naked {
_asm
push psw
jnb psw.1, 00001$ ; if user bit not set, jump to firmware irq
pop psw
lcall _uartInterrupt ; otherwise jump to bootloader irq
reti
00001$:
pop psw
ljmp #FIRMWARE_OFFSET IRQ_S0 ; firmware irq
_endasm;
}
// repeat for the other irqs
</cpp>
This code jumps to bootloader interrupt if PSW.1 (also called F1) is set to 1, otherwise it jumps to firmware.
<cpp>
// Code in bootloader
void main() {
// ...
F1 = 1; // relocate interrupts to bootloader
EA = 1; // global interrupt enable
// ...
}
</cpp>
<cpp>
// Code in firmware
void main() {
// ...
F1 = 0; // relocate interrupts to FIRMWARE_OFFSET (0x0800)
EA = 1; // global interrupt enable
// ...
}
</cpp>
Interrupt Vector Table (Not Used Method)
The following code shows another way that could have been used. Its advantage is that the interrupt vector can be relocated to any address dynamically. The disadvantage is that there's bigger overhead.
<cpp>
// Code in bootloader
// Redirects UART IRQ either into our (bootloader's) handler or into firmware handler.
void R_uartInterrupt() __interrupt (4) _naked {
_asm
mov a, _IrqVector ; compare IrqVector to 0
jnz 00001$
mov a, (_IrqVector 1)
jz 00002$
00001$: ; if not 0, then we need to jump to it
mov dpl, _IrqVector
mov dph, (_IrqVector 1)
mov a, #0x23 ; this is the offset for uart irq
jmp @a dptr ; call the interrupt handler in firmware
00002$: ; if it's 0, then we'll handle the irq
lcall _uartInterrupt ; call our own interrupt handler
reti
_endasm;
}
// repeat for the other irqs
</cpp>
IrqVector is a global variable that is set to the location of interrupt vector before enabling interrupts. The bootloader should set IrqVector to 0 while the program should set it to it's location.
<cpp>
// Code in firmware
__data __at (0x7e) unsigned int IrqVector;
void main() {
// ...
IrqVector = 0x0800; // we're relocated to 0x0800
EA = 1; // global interrupt enable
// ...
}
</cpp>