CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Question about bootloaders

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
simonspt



Joined: 12 Feb 2012
Posts: 10

View user's profile Send private message

Question about bootloaders
PostPosted: Thu Feb 16, 2012 6:21 pm     Reply with quote

Hi there!
I built up a pcb with a rs232 link and a dsPIC33 .. now i would like to program the mcu with a bootloader and the rs232 link

here's come the dumb question...
do i have to include the bootloader in my application, or first i have to program the device with a plain bootloader (for PCD devices, like loader_pcd.c in PICC/Drivers directory from CCS) and write my own application separately in another project?

sorry for the dumb question but i tried some examples from CCS (like ex_pcd_bootload.c) and i always get "Timeout while downloading software" from SIOW.exe (i've turned on XON/XOFF flow control)

somebody could help me?
thanks a lot!
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 16, 2012 8:24 pm     Reply with quote

Last bootloaders I cut were for a 68HC11 system....
but in 'principal'....

simply think this way...

the bootloader gets data from the PC and has to store it into the PIC. Storing means 'burning ' the PIC which takes time, so the PC program(SIOW or other terminal/downloading') has to wait xxx amount of time to be sure the data that just got sent has been 'processed' by the bootloader in the PIC and 'delivered' to the right location before the next data is sent.

An 'open' system just waits say ,1 second, for every byte to be processed..a system with 'handshaking(eg. XON/XOFF) can go as fast as it gets 'verification' that the data is where it should be.

Obviously the second way is faster...
The bootloader program should have instructions on how it is supposed to be run.
simonspt



Joined: 12 Feb 2012
Posts: 10

View user's profile Send private message

PostPosted: Fri Feb 17, 2012 6:44 am     Reply with quote

Thanks for your explanation! I tried using the loader_pcd.c that comes with ccs compiler, but when I call the bootloader from my application, it seems to hang when erasing the flash memory. After that if i try to cycle the power of the mcu, i must reprogram it with icsp and icd2 otherwise no application is run ..
Any suggestion?

Thanks!
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Feb 17, 2012 7:03 am     Reply with quote

Had a quick look at the loader programs(example) and driver.
comments.

The example has 'setup' code for 2 or 3 specific processors, so I'd hope you've modified to suit whatever peripherals you have on your PIC...

The driver( the actual bootloader) does use XON/XOFF for the 'pacing' or transferring of data,so you must have SIOW using it.

I'd try using the example programs to download a 'Hello World'/blinking LED program first..before trying anything complicated.Be sure the test program is in Intel format(read that in the code...).
simonspt



Joined: 12 Feb 2012
Posts: 10

View user's profile Send private message

PostPosted: Fri Feb 17, 2012 11:22 am     Reply with quote

I think the problem isn't the hex file itself, but is in the bootloader source code..

when i goto to LOADER_ADDR from my application, the "real_load_program" routine hangs here:
Code:

for(address_erase=0;address_erase<(LOADER_ADDR);address_erase+=(getenv("FLASH_ERASE_SIZE")/2))
   {
      erase_program_memory(address_erase);
   }
simonspt



Joined: 12 Feb 2012
Posts: 10

View user's profile Send private message

Solved!
PostPosted: Fri Feb 17, 2012 1:57 pm     Reply with quote

Ok I found the error! I didn't add the #ORG line to reserve memory for the bootloader, so every time I was compiling my application, the bootloader segment was overwritten..
now I added #ORG LOADER_ADDR,LOADER_END {} to my application and it works like a charm!

I'm using Hyperterminal to send the HEX compiled with ccs compiler.. I'm sending it out as plain text file, 19200bps 8bit N parity 1 bit stop with Xon/Xoff flow control Smile

Thanks for all the help!!!

[EDIT] When using the bootloader, make sure you disable all interrupts before reprogramming the device..! I put some debugging printf functions in my bootloader, and i noticed that if i don't disable interrupts before reprogramming, the erasing procedure hangs at 0x00000 .. now it's working fine with hyperterminal Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group