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 support@ccsinfo.com

Timed Serial Bootloader

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



Joined: 16 Dec 2019
Posts: 5

View user's profile Send private message

Timed Serial Bootloader
PostPosted: Thu Jan 02, 2020 8:18 am     Reply with quote

PIC 18F1320

I realised last week that insofar as I'm successfully transmitting and receiving "RS232-like" data over a BT link using an HC-05 (Using both an Android app and a Delphi application for Windows 10), it should, in theory, also be possible to update the PIC application hex code over the same serial link.

I've never actually used a bootloader before, I've only used a PICKit 2 - works fine. But here's the thing, the hardware is situated remotely and so re-programming the device is a bit of a pain.

Also, it would be far better if the bootloader, rather than looking for a pin that's taken low upon reset (I can reset the PIC over the Bluetooth link), just waits (2 second timer) to see if there is an update and then, if not, runs the main application code. It would be soooo convenient to be able to update the code via the HC-05.

I've tried to understand from various posts how to do this but I've just ended up confusing myself witless. Could someone kindly point me to exactly the correct timer based bootloader hex file for the 18F1320 and a PC app that will (without fuss) blow the application hex?
asmallri



Joined: 12 Aug 2004
Posts: 1630
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: Timed Serial Bootloader
PostPosted: Thu Jan 02, 2020 11:14 am     Reply with quote

GegFord wrote:
PIC 18F1320

I realised last week that insofar as I'm successfully transmitting and receiving "RS232-like" data over a BT link using an HC-05 (Using both an Android app and a Delphi application for Windows 10), it should, in theory, also be possible to update the PIC application hex code over the same serial link.

I've never actually used a bootloader before, I've only used a PICKit 2 - works fine. But here's the thing, the hardware is situated remotely and so re-programming the device is a bit of a pain.

Also, it would be far better if the bootloader, rather than looking for a pin that's taken low upon reset (I can reset the PIC over the Bluetooth link), just waits (2 second timer) to see if there is an update and then, if not, runs the main application code. It would be soooo convenient to be able to update the code via the HC-05.

I've tried to understand from various posts how to do this but I've just ended up confusing myself witless. Could someone kindly point me to exactly the correct timer based bootloader hex file for the 18F1320 and a PC app that will (without fuss) blow the application hex?


Hi George,
You mentioned the PIC is remote but that you want to to be bootloaded over Bluetooth using a HC-05 module which is only a short range device/technology. Can you explain what you mean by remote?

Using a timed bootloader mechanism is pretty typical approach however...

Any transmission over a wireless technology is prone to corruption as a result of contention to the airwaves and general interference from other sources. To address this class of problem, error detection and correction to both the programmer application and the bootloader itself is required to enable errored or missed packets to be re-transmitted. You would not generally find this capability in a traditional serial bootloader. The required error detection and correction code naturally increases the size of the bootloader.

In your specific case, you are using a really low end PIC. You will be challenged by issues such as the small amount of program memory, the limited amount of RAM to work with, and the PIC erase block size. I personally think it is impractical to do deploy this class of bootloader on this PIC.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19222

View user's profile Send private message

PostPosted: Thu Jan 02, 2020 1:09 pm     Reply with quote

Seriously, to do a Bluetooth bootloader, you are going to have to add
proper serial error recovery to your protocol. Bluetooth serial is not
a reliable data transmission medium. This will make bootloading a
very difficult thing to implement. Adding proper error correction, and then
the required pausing, will make the bootloader significantly larger, and
the program you use to send the data will have to implement the other
'half' of this.
You will also have to implement reconnection if the link breaks.
Though Bluetooth implements error correction, the HC-05 modules are 'notorious' for not for not doing this very well. They don't reliably trigger
retransmission when a packet is lost. This though does depend on whether
these are genuine modules or 'clones' and what firmware is installed.
Ideally do a long term data reliability test in a variety of different
conditions. You need to be able to guarantee reliable comms before even
thinking about using this for a bootloader....
GegFord



Joined: 16 Dec 2019
Posts: 5

View user's profile Send private message

PostPosted: Thu Jan 02, 2020 1:48 pm     Reply with quote

Hello Andrew,
The PIC is located at the back of the house. We live off-grid. The PIC is monitoring and logging the kWh from the PV panels that we have, and the inverter/12V LED lighting usage etc. It's also controlling the switching in and out of the satellite receiver, the inverter and the water pump.

It's actually less than 10m away but outside, in an enclosure, whilst I'm inside next to the fire. Data heaves backwards and forwards and so far I haven't noticed any corruption. That's not to say there isn't any, I do have parsing in play at both ends - so to speak.

Anyway, not to worry, if it's too dodgy to implement then that's fine. Thanks for the input (no pun intended)...
temtronic



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

View user's profile Send private message

PostPosted: Thu Jan 02, 2020 5:25 pm     Reply with quote

just a comment....
these 'wireless' com devices require HUGE amount of overhead for the actual 'payload' or data being sent.
Yeah, I'm a 'fossil'..still running 22 bits of adrs/data/ctrl at 24 Baud, direct wire, 15 miles,hacker proof too. Original micro was 6800 based, 8KB EPROM. If you saw the list of functions/features this machine does you'd understand why I HATE 'bloatware'.
GegFord



Joined: 16 Dec 2019
Posts: 5

View user's profile Send private message

PostPosted: Fri Jan 03, 2020 9:21 am     Reply with quote

Well, I'll go to the foot of our stairs - it works!!

I found a bootloader written by Martin Dubuc. He supplies specific 18F device bootloader hex files (including the 18F1320) and some test code. I gave it try and bingo, it worked perfectly over the BT link. I then tried to upload my firmware and although it took about 30 seconds, at 9600, it worked perfectly.

I'll do some tests to see over what distance it will work reliably.

Temtronic, I'm really interested in your long distance, low baud rate project, I'll send you a PM if that's alright.
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