View previous topic :: View next topic |
Author |
Message |
kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Fri Dec 04, 2020 11:53 am |
|
|
Ttelmah wrote: | 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. |
With set "GSSK" fuse also doesn't start bootloader. This is my full code:
Code: |
#include <33EP512MU810.h>
#fuses NOWDT,RESET_AUX,NOIOL1WAY,GSSK //The RESET_AUX fuse causes PIC to reset into Auxiliary Memory
#build (AUX_MEMORY) //Build code for Auxiliary Memory
#use delay(clock=32MHz, crystal=8MHz)
/* HW UART1 */
#pin_select U1RX=PIN_E1 // Rx Com1.
#pin_select U1TX=PIN_E0 // Tx Com1.
#define EN1_485 PIN_D1 // RE/DE Com1.
#use rs232(UART1,baud=38400,errors,enable=EN1_485)
#define PUSH_BUTTON PIN_G9
//The following defines are necessary to use PCD's serial bootloader, loader_pcd.c.
#define _bootloader
#define LOADER_SIZE 0
#define APPLICATION_START 0
#define APPLICATION_END getenv("PROGRAM_MEMORY")
//Include PCD's serial bootloader
#include <loader_pcd.c>
void main(void)
{
if(!input(PUSH_BUTTON))
{
delay_ms(140); // wait for PLL
printf("\r\nBootloader Version 1.0\r\n");
// Let the user know it is ready to accept a download
printf("\r\nWaiting for download...");
// Load the program
load_program();
}
goto_address(APPLICATION_START);
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19244
|
|
Posted: Sat Dec 05, 2020 3:38 am |
|
|
No, You need to set PROTECT, _and_ GSSK. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Sat Dec 05, 2020 5:54 am |
|
|
With this option:
Code: |
#fuses NOWDT,RESET_AUX,NOIOL1WAY,GSSK,PROTECT |
bootloader start, but application does not start. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9123 Location: Greensville,Ontario
|
|
Posted: Sat Dec 05, 2020 6:19 am |
|
|
Though I don't use a bootloader...
My understanding is that BOTH bootloader and application program must have the SAME 'fuses' though using #FUSES NONE in the bootloader may work ?
'PROTECT' seems to be 'global', similar to interrupts and you then need to specify what memory banks areas are to be protected
I've never used 'protect' in 2.5 decades, no real need for it.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19244
|
|
Posted: Sat Dec 05, 2020 9:38 am |
|
|
Yes. If these bits are not set the same in the application code, that will
prevent it from running. It'll be seen as a 'non permitted' access. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Sat Dec 05, 2020 10:18 am |
|
|
I don't think so. This is sample application program with same #fuses, which not run after load through pcd_aux bootloader.
Also this bootloader has following option:
//// The config bits will be write protected, in software, by the ////
//// rom_modify() function. To allow config bits to change then ////
//// you need to #define ROM_WRITE_CAN_MODIFY_CONFIG_BITS
Code: |
#include <33EP512MU810.h>
#fuses NOWDT,RESET_AUX,NOIOL1WAY,PROTECT,GSSK //The RESET_AUX fuse causes PIC to reset into Auxiliary Memory
#use delay(clock=32MHz, crystal=8MHz)
/* HW UART1 */
#pin_select U1RX=PIN_E1 // Rx Com1.
#pin_select U1TX=PIN_E0 // Tx Com1.
#define EN1_485 PIN_D1 // RE/DE Com1.
#use rs232(UART1,baud=38400,errors,enable=EN1_485)
#define LED1 PIN_A6
void main(){
delay_ms(300);
while(true){
printf("\r\nApplication runing..\r\n");
output_toggle(LED1);
delay_ms(500);
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19244
|
|
Posted: Sun Dec 06, 2020 3:57 am |
|
|
The ROM_WRITE_CAN_MODIFY_CONFIG_BITS, affects whether the
bootloader, and therefore the program being loaded can change the config.
You didn't tell us whether your bootloader had this setting, till this was raised.
Does the example program work if you load it using the programmer, with
RESET_AUX removed?.
Problem is that the effect of protections varies for almost every chip. On the
PIC24/33, the code itself does use table reads to access the program memory
for consts. On some chips you can leave this enabled for the code, but
disable if for the programmer (so protecting against reads using a
programmer), but on others, enabling this will prevent the code from
running. It doesn't sound as if yours is like this, since the bootloader runs.
Your chip doesn't seem to offer the option to specify what pages can be read
(most have a table of bits allowing you to specify this). |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Sun Dec 06, 2020 5:55 am |
|
|
Hi mr."Ttelmah",
1.I don't use "ROM_WRITE_CAN_MODIFY_CONFIG_BITS" in bootloader program.
2. Quote: |
Does the example program work if you load it using the programmer, with
RESET_AUX removed?. |
Yes, application program work with:
Code: | #fuses NOWDT,NOIOL1WAY,PROTECT,GSSK |
3. Example application program above work also when load through "pcd_aux_bootloader" with bootloader fuses:
#fuses NOWDT,RESET_AUX,NOIOL1WAY,NOPROTECT,NOGSSK |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19244
|
|
Posted: Sun Dec 06, 2020 7:23 am |
|
|
OK. I think you are going to have to use the manual fuse option.
Problem is that the CCS fuse names and the actual fuses needed are
not aligning quite right. You need the following fuse pattern:
GSSK 01 (1 in the low bit and 0 in high)
GSS on
GSWP off (otherwise the bootloader can't write).
Now they seem to be only offering GSSK = 00 or GSSK = 11, which
are the options needed for no protection or full protection.
Now this is 0xF80004 = 0b00100010.
So get rid of the GSSK and GSS settings and instead use a manual fuse
setting for this register. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Sun Dec 06, 2020 10:30 am |
|
|
Something like this:
Code: |
#fuses NOWDT,RESET_AUX,NOIOL1WAY,PROTECT
#byte FGS = 0xF80004
#bit GWRP = FGS.0
#bit GSS = FGS.1
#bit GSSK_b4 = FGS.4
#bit GSSK_b5 = FGS.5
void main(void)
{
GWRP = 0;
GSS = 1;
GSSK_b4 = 1;
GSSK_b5 = 0;
.................
}
|
? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19244
|
|
Posted: Sun Dec 06, 2020 11:37 am |
|
|
No.
Fuses, can be done by name, or explicitly as numbers.
So you can have #fuses 4=xxxx
To explicitly set fuse register 4 to the value xxxx. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Sun Dec 06, 2020 12:23 pm |
|
|
mr."Ttelmah" please explain how to know GSSK=4 and "xxxx" value is bit,byte,word etc. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19244
|
|
Posted: Sun Dec 06, 2020 1:39 pm |
|
|
I've already told you the value. Look at my earlier post,
GSSK does not equal 4. The GSSK bits are just two bits in this particular
fuse register. You need the same pattern in these two bits as the combination
of the GSWP and GSS bits. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Sun Dec 06, 2020 1:42 pm |
|
|
I'm sorry, I didn't understand that this is just an example.
In my case I have to set #fuses config word 0 or 1?
Configuration Words
F80004: 00FF0003 00FF0080 00FF0001 00FF007F
F8000C: 00FF0037 00FF00D3 00FF0003 |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Sun Dec 06, 2020 2:01 pm |
|
|
The only thing that i found in manual is:
Quote: |
To manually set the fuses in the output files use: #FUSES 1 = 0xC200 // sets config word 1 to 0xC200 |
but when I set nothing changed in generated hex file at config data words |
|
|
|