Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I have been trying to assemble ds30loader with xc16 in MPLABX for a pic24f. For some reason it is generating a .text section starting at 0x200 for __data_init_standard (according to the map file). I guess that there is some linker setting that I need, but I can not work it out. When I inspect the program it is clear that the 0x0 goto vector points to the bootloader program towards the end of program memory, but the bootloader does not seem to work.

Does the bootloader need the __data_init_standard section, and should that section actually be part of the bootloader program in memory? If so, how do I change the linker or assembler settings to put it in the right place?

I know I could just build it in MPLAB with C30, but I would have to download and configure all of that. MPLAB X is pretty stable since version 2.00 so I figure it is time to make sure we can compile ds30loader in it.
Please zip and post the boot loader project and I will take a look at it.
(2014-07-15, 00:07:31)Mikael Gustavsson Wrote: Hi,
Please zip and post the boot loader project and I will take a look at it.

Thanks Micke. The file is attached.

.zip (Size: 150.7 KB / Downloads: 55)
Thanks. You don't need to worry about linker scripts and such things.
I notice that you haven't configured the configuration bits. That's most likely why the boot loader seem to not work.
(2014-07-19, 12:28:40)Mikael Gustavsson Wrote: Thanks. You don't need to worry about linker scripts and such things.
I notice that you haven't configured the configuration bits. That's most likely why the boot loader seem to not work.

Thanks Mikael. I manged to get the bootloader working. I can now assemble it with either XC16 or with ASM30 in MPLABX. This is what I did:
- Import the 16bitfirmware MPLAB 8.x project into MPLABX. I selected the right processor (PIC24F32KA301) etc.
- To get it working with ASM30 I had to explicitly add the processor specific linker file to the project.
- With both ASM30 and XC16 I had to set the assembler include directories properly.
- I altered settings according to your instructions. I set the CONFIG bits to match my application like this:
.ifdef    IS_24F
            config    __FBS,    BSS_OFF/*Boot Segment Code Protect*/ & BWRP_OFF/*Boot Segment Write Protect Enable*/
            config    __FGS,    GSS0_OFF/*General Segment Code Protect*/ & GWRP_OFF/*General Segment Write Protect Enable*/
            config    __FOSCSEL,    FNOSC_FRCPLL/*Initial Oscillator Select*/ & IESO_OFF/*Two Speed Start-up*/ & SOSCSRC_DIG & LPRCSEL_HP
            config    __FOSC,    FCKSM_CSDCMD/*Clock switching and Fail-Safe Clock monitor*/ & SOSCSEL_SOSCHP/*Secondary Oscillator Select*/ & POSCFREQ_HS/*Primary Oscillator Frequency Range*/ & OSCIOFNC_OFF/*OSCO Pin Configuration*/ & POSCMOD_NONE/*Oscillator Selection*/
            config    __FWDT,    FWDTEN_OFF/*Watchdog Timer*/ & WINDIS_OFF/*Windowed WDT*/ & FWPSA_PR128/*Watchdog prescaler*/ & WDTPS_PS32768/*Watchdog postscale*/
            config    __FPOR, MCLRE_ON/*Master Clear Enable*/ & BORV_V18/*Brown Out Voltage*/ & I2C1SEL_PRI/*I2C1 pins Select*/ & PWRTEN_ON/*Power Up Timer*/ & BOREN_BOR3/*Brown Out Reset*/ & LVRCFG_OFF
            config    __FICD, ICS_PGx2/*ICD pins select*/
            config    __FDS,    DSWDTEN_OFF/*Deep Sleep Watchdog Timer*/ & DSBOREN_OFF/*Deep Sleep BOR*/ & DSWDTOSC_LPRC/*Deep Sleep Watchdog Oscillator Clock Select*/ & DSWDTPS_DSWDTPSF/*Deep Sleep Watchdog Postscale*/

- I also had include 'clr ANSB' at the beginning of the UserInit macro to ensure the UART2 Rx is digital rather than analog.

While both assemblers work, they do produce slightly different output. The goto at 0x00 and the actual boot loader code from 0x5640 is the same. However, both assemblers produce a code at 0x200. First, ASM30 produces this:
257    200    DA4000        BREAK    0
258    202    FE0000        RESET    0
However, xc16-as produces this:
257    200    880191        MOV W1, TBLPAG    
258    202    780080        MOV W0, W1    
259    204    EB0000        CLR W0    
260    206    370015        BRA 0x232    
261    208    4.08E+05    L11    ADD W1, #0x2, W1    
262    020A    B4A032        ADDC TBLPAG    
263    020C    BA0191        TBLRDL [W1], W3    
264    020E    4.08E+05        ADD W1, #0x2, W1    
265    210    B4A032        ADDC TBLPAG    
266    212    BA0291        TBLRDL [W1], W5    
267    214    4.08E+05        ADD W1, #0x2, W1    
268    216    B4A032        ADDC TBLPAG    
269    218    EB0200        CLR W4    
270    021A    DE2B47        LSR W5, #7, W6    
271    021C    B207F5        AND #0x7F, W5    
272    021E    E12C60        CP.B W5, #0    
273    220    3A0004        BRA NZ, 0x22A    
274    222    EB5900    L91    CLR.B [W2++]    
275    224    E90183        DEC W3, W3    
276    226    3EFFFD        BRA GTU, 0x222    
277    228    370004        BRA 0x232    
278    022A    E12861    L21    CP W5, #1    
279    022C    320001        BRA Z, 0x230    
280    022E    EB8200        SETM W4    
281    230    70004    L31    RCALL 0x23A    
282    232    BA0111    L41    TBLRDL [W1], W2    
283    234    E00002        CP0 W2    
284    236    3AFFE8        BRA NZ, 0x208    
285    238    60000        RETURN    
286    023A    BA5931    L12    TBLRDL.B [W1++], [W2++]    
287    023C    E90183        DEC W3, W3    
288    023E    32000C        BRA Z, 0x258    
289    240    BA5921        TBLRDL.B [W1--], [W2++]    
290    242    E90183        DEC W3, W3    
291    244    320008        BRA Z, 0x256    
292    246    E00004        CP0 W4    
293    248    3A0003        BRA NZ, 0x250    
294    024A    4.08E+05    L32    ADD W1, #0x2, W1    
295    024C    B4A032        ADDC TBLPAG    
296    024E    37FFF5        BRA 0x23A    
297    250    BAD911    L13    TBLRDH.B [W1], [W2++]    
298    252    E90183        DEC W3, W3    
299    254    3AFFFA        BRA NZ, 0x24A    
300    256    E80081    L42    INC W1, W1    
301    258    4.08E+04    L22    ADD W1, #0x1, W1    
302    025A    B4A032        ADDC TBLPAG    
303    025C    60000        RETURN    
304    025E    DA4000    .isr    BREAK    
305    260    FE0000        RESET
I have spend some time trying to understand where this comes from. I am sure there is some assembler setting. The GUI works fine with both versions, so I guess it does not matter. Though, I wish I understood better.
Thanks for the report. 0x200 is the start address of the application. XC16 produces code to initialize variables. It is not needed by the boot loader and it will be overwritten by the application. You can turn it of by the "Don't initialize data sections" linker option. When you do the output will be the same as with ASM30.

Forum Jump:

Users browsing this thread: 1 Guest(s)