![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
allenhuffman
Joined: 17 Jun 2019 Posts: 540 Location: Des Moines, Iowa, USA
|
Implementing a simple bootloader |
Posted: Fri Nov 01, 2019 3:23 pm |
|
|
My system does not have ex_bootload.c/ex_bootloader.c in the Examples folder, so maybe those answer some questions I am about to ask.
I am toying with implementing a very simple bootloader for disaster recovery. The goal is to have the system always start with the bootloader code, then it will decide to jump to an APPLICATION in memory, or accept an upload of new firmware to whatever address I load it to.
BOOTLOADER will be simple and not use interrupts. It will probably implement Traps.c to catch all bad exceptions (division by zero, etc.) so we can detect and recover from that.
I see I can use #BUILD and #ORG to move things around, so it appears I would need to have the RESET vector stay normal, pointing to bootloader code. Since the application code will want interrupts, I see how I can alter the BOOTLOADER's vector table so they point omewhere else (where no code exists). Then I can use #BUILD to make the APPLICATION's ISR/vector table stuff live there in the HEX file.
I'll post a diagram of what I envision next week.
It looks pretty straight forward and simple. Any gotchas I should be aware of? _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Fri Nov 01, 2019 5:04 pm |
|
|
You must have a really old compiler as mine has them, dated 2005.
if you ask CCS, they may send them to you. A few years ago I asked for the current 'examples' folder and within minutes they sent them to me.
Jay |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Sun Nov 03, 2019 3:00 am |
|
|
I've just done a search back, and even the V3 compilers have these
examples. Back to 2003 (gave up at this point). The examples as a whole
are a critical part of the documentation of the compiler. Re-install if they
are missing (the install includes them).
A lot depends on what chip is involved?. I'm significantly 'puzzled', since you
are posting questions on other threads which seem to involve PCD. This
wasn't even launched till well after these examples existed.
What chip are you actually trying to use, and what compiler version do you
have?. This also affects some of the answers you have already been given,
since some of the very early compilers do not do some of the things that
are 'assumed' on later versions. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 03, 2019 3:50 am |
|
|
If the examples are missing, it could be that:
1. He's using the CCS demo and not telling us. CCS says the demo only
has 15% of the available examples and drivers.
http://www.ccsinfo.com/ccsfreedemo.php
2. His IT department has doctored his installation and removed the examples.
I favor number 1. |
|
![](templates/subSilver/images/spacer.gif) |
allenhuffman
Joined: 17 Jun 2019 Posts: 540 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Nov 04, 2019 8:24 am |
|
|
PCM programmer wrote: | If the examples are missing, it could be that:
1. He's using the CCS demo and not telling us. CCS says the demo only
has 15% of the available examples and drivers.
http://www.ccsinfo.com/ccsfreedemo.php
2. His IT department has doctored his installation and removed the examples.
I favor number 1. |
I show IDE 5.087 and PCD 5.082. Our release is locked to an older release of the compiler.
I have an Examples folder with plenty of files, but not those two.
But I don't think I need the examples since this looks really simple to implement with the PIC architecture. It took maybe 10 minutes to get a proof-of-concept going with some code at the start that fires up first, then jumps to a second block of code we can load separately. The only thing I had to look into was redirecting the vector table. I now have a GOTO to a GOTO, but it works. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Mon Nov 04, 2019 10:42 am |
|
|
Seriously you should investigate what examples are mising.
You version does have those examples. If re-iinstalling does not add them,
ask CCS for them.
Things that are in the compiler which you need the examples to see
are functions like 'jump_to_isr' which is needed for ISR relocation, and
how to handle the runtime version relocation.
Get the examples. |
|
![](templates/subSilver/images/spacer.gif) |
allenhuffman
Joined: 17 Jun 2019 Posts: 540 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Nov 04, 2019 3:32 pm |
|
|
Ttelmah wrote: | Seriously you should investigate what examples are mising.
You version does have those examples. If re-iinstalling does not add them,
ask CCS for them.
Things that are in the compiler which you need the examples to see
are functions like 'jump_to_isr' which is needed for ISR relocation, and
how to handle the runtime version relocation.
Get the examples. |
Most certainly. I've already contacted them, but I check the forums first. I think one of the issues is folks that have been using it for awhile may not be aware of the state of a "fresh install" these days. Broken links in the help file (missing files) and such.
I'd found jump_to_isr() in other examples and posts here, which I hope to use to replace my inline assembly code. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
![](templates/subSilver/images/spacer.gif) |
allenhuffman
Joined: 17 Jun 2019 Posts: 540 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Nov 04, 2019 4:06 pm |
|
|
They got me the missing files already. Nice. (The sent me four files.)
Very straight forward (not much in them) -- I'd already figured out #org and #build like they use, and had located jump_to_isr(int16 address). I was having compile issues and hoped their examples would shed some light, but it's the same...
For example...
Code: | #define LOADER_END 0x4ff
. . .
#int_global
void isr(void) {
jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
} |
Trying to build for 24EP256GP202 (just an old board I have handy) does not like #INT_GLOBAL ("Invalid Pre-Processor Directive") and can't build the jump_to_isr() line ("A numeric expression must appear here").
Actually, even trying to just get...
jump_to_isr (0x2000);
...won't compile. Sometimes the compiler gets in a mood where things won't resolve (like earlier issues I had with pointers -- the code would build, unless I moved it down a few dozen lines then it gave compiler errors).
I'm guessing this is just another one of those. This is a fresh test project with pretty much everything removed beyond some defines (to calculate the ORG/BUILD/etc.) and a while(1) in main.
Whac-whac-whac ;-) _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 04, 2019 4:19 pm |
|
|
What files are you looking at ? You should tell us. Never assume we know.
You should be looking at these files:
Quote: | EX_PCD_BOOTLOAD.C
EX_PCD_BOOTLOADER.C |
|
|
![](templates/subSilver/images/spacer.gif) |
allenhuffman
Joined: 17 Jun 2019 Posts: 540 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Nov 04, 2019 4:23 pm |
|
|
PCM programmer wrote: | What files are you looking at ? You should tell us. Never assume we know.
You should be looking at these files:
Quote: | EX_PCD_BOOTLOAD.C
EX_PCD_BOOTLOADER.C |
|
Per the "Examples Program" entry in the Help file:
Quote: | EX_BOOTLOAD.C
A stand-alone application that needs to be loaded by a bootloader (see ex_bootloader.c for a bootloader).
EX_BOOTLOADER.C
A bootloader, loads an application onto the PIC (see ex_bootload.c for an application). |
Support sent me those two files, including bootloader.h and loader.c
While my Examples folder contains 173 files, those seem to have been omitted from the installer. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 04, 2019 4:36 pm |
|
|
You need to ask CCS for the PCD files. Like I said, tell people what you
are doing. Tell CCS you are using a 24F PIC. Then they would have
sent you the correct files. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Mon Nov 04, 2019 11:06 pm |
|
|
and, what is in my directory for every install, is what you get if you do
a 'fresh install', and all these files are included. How on earth your version
lacks them is weird, unless as PCM earlier suggested you actually
originally did a 'demo version' install. |
|
![](templates/subSilver/images/spacer.gif) |
allenhuffman
Joined: 17 Jun 2019 Posts: 540 Location: Des Moines, Iowa, USA
|
|
Posted: Tue Nov 05, 2019 8:27 am |
|
|
PCM programmer wrote: | You need to ask CCS for the PCD files. Like I said, tell people what you
are doing. Tell CCS you are using a 24F PIC. Then they would have
sent you the correct files. |
Yes, they sent me four files. I'm now waiting to see if they can figure out the compiler issue. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Last edited by allenhuffman on Tue Nov 05, 2019 8:33 am; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
allenhuffman
Joined: 17 Jun 2019 Posts: 540 Location: Des Moines, Iowa, USA
|
|
Posted: Tue Nov 05, 2019 8:28 am |
|
|
Ttelmah wrote: | and, what is in my directory for every install, is what you get if you do
a 'fresh install', and all these files are included. How on earth your version
lacks them is weird, unless as PCM earlier suggested you actually
originally did a 'demo version' install. |
I certainly had plenty of Examples there... just not the one I was looking for ![Smile](images/smiles/icon_smile.gif) _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Nov 05, 2019 8:56 am |
|
|
Did you actually try a re-install?.
This is the list of files that should be there:
Quote: |
ex_14kad.c
ex_1920.c ex_23s17.c
ex_8pin.c ex_92lcd.c
ex_ad12.c ex_adc_epgs.c
ex_admm.c ex_admm10.c
ex_admm_sleep.c ex_admm_stats.c
ex_bootload.c ex_bootloader.c
ex_bootloader_to_i2c.c ex_can.c
ex_can_ccs_a.c ex_can_ccs_b.c
ex_capture.c ex_ccp1s.c
ex_ccpmp.c ex_center_aligned_pwm.c
ex_checksum.c ex_cni.c
ex_comp.c EX_CRC.C
EX_CRC_HW.C EX_CUST.C
ex_dbgmon.c ex_dma_adc.c
ex_dma_pingpong.c ex_dma_uart_rx.c
ex_dmx_controller.c ex_dmx_slave.c
ex_dnslookup.c ex_dpot.c
ex_dtmf.c ex_edge_aligned_pwm.c
ex_email.c ex_encod.c
ex_encry.c EX_EXPIO.C
ex_exsio.c ex_extdynmem.c
ex_extee.c ex_ezapp_backgrounds.c
ex_ezapp_buttons.c ex_ezapp_colorpicker.c
ex_ezapp_common.h ex_ezapp_dual.c
ex_ezapp_graphing.c ex_ezapp_gui.c
ex_ezapp_images.c ex_ezapp_joystick.c
ex_ezapp_pot.c ex_ezapp_security.c
ex_ezapp_strings.c ex_ezapp_style.c
ex_fat.c ex_fft.c
ex_fft_filter.c ex_fir.c
ex_fixed.c ex_float.c
ex_freqc.c ex_glcd.c
ex_glint.c ex_graph_siow.c
ex_hpint.c ex_hspwm.c
ex_humidity.c ex_i2c_ldr_application.c
ex_i2c_ldr_bootloader.c ex_i2c_master_hw_k42.c
ex_i2c_slave_k42.c ex_icd.c
ex_intee.c ex_intfl.c
ex_j1939.c ex_j1939b.c
EX_LCDKB.C ex_lcdth.c
EX_LED.C ex_linbus_master.c
ex_linbus_slave.c ex_load.c
ex_logger.c ex_lowpass_filter_adc2.c
ex_macro.c ex_malloc.c
ex_mcr.c ex_mmcsd.c
ex_modbus_master.c ex_modbus_slave.c
ex_motor_pwm.c ex_mouse.c
ex_mxram.c ex_patg.c
ex_pbusm.c ex_pbusr.c
ex_pbutt.c ex_pcd_aux_bootload.c
ex_pcd_aux_bootloader.c ex_pcd_bootload.c
ex_pcd_bootloader.c ex_pcd_checksum.c
ex_pcd_load.c ex_pcd_stwt1.c
ex_pgen.c ex_pid.c
ex_pinselect.c ex_pinselect2.c
ex_pll.c ex_power_pwm.c
ex_profile.c ex_psmc_complementary.c
ex_psmc_complex.c ex_psmc_simple.c
ex_psp.c EX_PULSE.C
EX_PWM.C ex_pwm_pcd.c
EX_PWM_USE.C EX_QSORT.C
ex_react.c ex_rfid.c
ex_rmsdb.c ex_rs232_485.c
ex_rs232_buffer.c ex_rs232_to_i2c.c
ex_rs485.c EX_RTC.C
ex_rtcc.c ex_rtclk.c
ex_rtctimer.c ex_rtos_demo_1_tasks.c
ex_rtos_demo_2_termination.c ex_rtos_demo_3_enable_disable.c
ex_rtos_demo_4_messages.c ex_rtos_demo_5_yield.c
ex_rtos_demo_6_semaphores.c ex_rtos_demo_7_await.c
ex_rtos_demo_8_statistics.c ex_rtos_demo_9_basic_kernal.c
ex_sim.c ex_sine.c
ex_sisr.c ex_sk_7seg_led.c
ex_sk_7seg_led_extracredit.c ex_sk_accelerometer.c
ex_sk_barometer.c ex_sk_gps.c
ex_sk_gps_extracredit.c ex_sk_hall_analog.c
ex_sk_hall_digital.c ex_sk_humidity.c
ex_sk_keypad.c ex_sk_keypad_extracredit.c
ex_sk_noise_detect.c ex_sk_photo_resistor.c
ex_sk_relay.c ex_sk_rgb_led.c
ex_sk_rotary_encoder.c ex_sk_rotary_encoder_isr.c
ex_sk_stepper.c ex_sk_stepper_extracredit.c
ex_sk_temp_digital.c ex_sk_temp_thermistor.c
ex_sk_touch.c ex_sk_ultrasonic.c
ex_sk_ultrasonic_ccp.c ex_sk_vibration.c
ex_slave.c ex_smt_period_duty.c
ex_smt_timer.c ex_speed.c
EX_SPI.C ex_spi_slave.c
EX_SQW.C ex_sram.c
ex_step.c ex_stisr.c
EX_STR.C ex_stwt.c
ex_stwt1.c ex_stwt2.c
ex_sync_master.c ex_sync_slave.c
EX_TANK.C EX_TEMP.C
ex_tgetc.c ex_tgetc2.c
ex_ticks.c ex_time.c
EX_TONES.C ex_touch.c
ex_usb_bootloader.c ex_usb_common.h
ex_usb_hid.c ex_usb_hid_and_cdc.c
ex_usb_kbmouse.c ex_usb_kbmouse2.c
ex_usb_keyboard.c ex_usb_keyboard_and_cdc.c
ex_usb_loadmouse.c ex_usb_multihid.c
ex_usb_multihid2.c ex_usb_scope.c
ex_usb_serial.c ex_usb_serial2.c
ex_usb_serial3.c ex_usb_to_serial.c
ex_use_capture.c ex_voice.c
EX_WAKUP.C ex_wdt.c
ex_wdt18.c ex_wdt_pcd.c
ex_websv.c ex_x10.c
ex_xtea.c ex_zmd.c
|
That directly pasted from the 5.078 install directory. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|