View previous topic :: View next topic |
Author |
Message |
kmp84
Joined: 02 Feb 2010 Posts: 349
|
Bootloader & PPS |
Posted: Tue Dec 01, 2020 2:24 pm |
|
|
Hello,
I'm using "pcd_aux_bootloader" for dsPic33EP512MU810 on hardware UART1 and application using UART1 and UART2. If UART2 not configured in bootloader (not set #pin_select Rx,Tx) it doesn't start also in application. Any workaround for this kinds of problems?
Best Regards!
Last edited by kmp84 on Fri Dec 04, 2020 9:30 am; edited 1 time in total |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 349
|
|
Posted: Tue Dec 01, 2020 4:21 pm |
|
|
I found the solution at the top of the forum "Sticky : How to use #pin_select" from Ttelmah's post:
Quote: |
One 'caveat' to add to this, applies with bootloaders.
If you have a bootloader, and it uses a PPS peripheral (so maps anything
with PPS), you need to ensure the NOIOL1WAY fuse is selected. Otherwise
your main code will not be able to change the pin settings.
The IOL1WAY fuse means that things can be set only once. Problem is if
the bootloader is setting them, then the 'main' code can't set them again....
|
Best Regards! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19512
|
|
Posted: Wed Dec 02, 2020 2:37 am |
|
|
Glad you found it. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 349
|
|
Posted: Wed Dec 02, 2020 3:15 am |
|
|
I'm thinking about how to start bootloader from application without switching some jumpers. For example receiving some command from UART "StartBoot\r\n". Any idea..? |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 349
|
|
Posted: Wed Dec 02, 2020 3:19 am |
|
|
One simple scenario that I can do is to Set flag in external i2c memory, restart dsPic and bootloader check for flag. Is it possible? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19512
|
|
Posted: Wed Dec 02, 2020 3:32 am |
|
|
The 'best' way I know of to do this, is to have the bootloader start, if the
RS232 is receiving 'break' when the chip starts. Since an TTL serial line
'idles high', and it is easy to add a pull up, to ensure this happens, the
code can simply test the line, and exit if it is high.
Then in your main code when you want to trigger the bootloader, just
tell your user to start your download program, which starts by sending
a 'break' (holding the line low), and then your code calls reset_cpu. The
chip then restarts, and sees the line low. It this point the bootloader starts
and sends a status to say "I'm here" to the attached program, which then
starts sending. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 349
|
|
Posted: Wed Dec 02, 2020 4:59 am |
|
|
Thanks mr.'Ttelmah',
Best Wishes! |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 349
|
|
Posted: Thu Dec 03, 2020 8:55 am |
|
|
Hello again,
How and where to protect aux&code memory from read?
Protect in bootloader or aplication? When protected in bootloader it doesn't start!
Best Regards! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19512
|
|
Posted: Thu Dec 03, 2020 1:39 pm |
|
|
In the bootloader. It should not allow any write to areas that should not
change. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 349
|
|
Posted: Fri Dec 04, 2020 9:26 am |
|
|
There is some errata issue (31. Module: Auxiliary Flash), but work around doesn't work. When I set below fuses bootloader doesn't start.
Code: |
#include <33EP512MU810.h>
#fuses NOWDT,RESET_AUX,NOIOL1WAY
#fuses PROTECT //with this line bootloader doesnt start!
#build (AUX_MEMORY) //Build code for Auxiliary Memory
#use delay(clock=32MHz, crystal=8MHz)
...............
|
CCS C v.5.093 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Fri Dec 04, 2020 9:42 am |
|
|
My guess is that 'PROTECT' prevents the bootloader from programming PROTECTED memory ???? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 04, 2020 10:03 am |
|
|
The dsPIC33EP512MU810 data sheet says:
Quote: | 29.8 Code Protection and CodeGuard™ Security
The dsPIC33EPXXX(GP/MC/MU)806/810/814 and
PIC24EPXXX(GP/GU)810/814 devices do not support
Boot Segment (BS), Secure Segment (SS) and RAM
protection. |
That's your PIC, and it doesn't support boot block protection. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 349
|
|
Posted: Fri Dec 04, 2020 10:54 am |
|
|
temtronic wrote: | My guess is that 'PROTECT' prevents the bootloader from programming PROTECTED memory ???? |
I don't get to programming at all. "pcd_aux_bootloader" doesn't start with "PROTECT" fuse. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 349
|
|
Posted: Fri Dec 04, 2020 11:01 am |
|
|
PCM programmer wrote: | The dsPIC33EP512MU810 data sheet says:
Quote: | 29.8 Code Protection and CodeGuard™ Security
The dsPIC33EPXXX(GP/MC/MU)806/810/814 and
PIC24EPXXX(GP/GU)810/814 devices do not support
Boot Segment (BS), Secure Segment (SS) and RAM
protection. |
That's your PIC, and it doesn't support boot block protection. |
Generally I want to protect code memory and if possible aux memory from reading. if that can't be done then what are purpose of"PROTECT,APROTECT" fuses? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19512
|
|
Posted: Fri Dec 04, 2020 11:37 am |
|
|
The key here is you need to set the GSSK bits as well as the GSS bit.
The GSS bit is the protect one you are setting, but if this is set, and not
the GSSK bits, this puts the chip into 'full protect' mode, which stops the
bootloader from being able to work. These are the 'general segment key'
bits. GSSK in the fuses. |
|
|
|