Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disable bootloader on compilation
08-10-2011, 09:58 AM,
#1
Disable bootloader on compilation
Hi there.

I know that the bootloading is one of the main ideas of the pinguino project.

I'm working right now on a project that involves usb communication (not serial over usb), interrupts, analog reading, among other functions. And the pinguino project is very helpful because it takes care of library loading and handful functions.

But in this project I'm working on (reading voltage and shooting various capacitor banks), I need all these functions, but the bootloading interfers with ISIS simulator (with the usb connection), and once the physical circuit has been made, we would not need the bootloading capability anymore.

So I was thinking, could be an option for pinguino to not integrate the bootloader into the output HEX file (to burn it later manually with a programmer)? or, how can I compile pinguino code into a HEX file without the bootloader? (compiling manually with sdcc, for example, but what code must be removed?)

By the way, thank you for making pinguino project open source! I'm reading the python scripts but I don't know how to start.

Thank you in advance!
Reply
08-10-2011, 12:43 PM,
#2
RE: Disable bootloader on compilation
Hi Otamay

Of course you can modify the code for making Pinguino Application Stand alone.
What board do you use ? ( Pinguino 8 bits, Pinguino 32 )

If it is the 8 bits board, you need to change the lkr file to remove protected zone ( from 0x0000 to 0x1FFF for the bootloader flash memory and from 0x400 to 0xFFF for the USB RAM memory ). The best solution is to use the original lkr file of sdcc.
Then in the compilation command line, you must link the standard runtime to the compiler ( crt0.o ) instead of the crt0pinguino.o.
Then you must remove the application_interface.o file to the linking line. This object file insure interfacing with the bootloader.

If you need some help, tell me !!

Jean-Pierre
(08-10-2011, 09:58 AM)Otamay Wrote: Hi there.

I know that the bootloading is one of the main ideas of the pinguino project.

I'm working right now on a project that involves usb communication (not serial over usb), interrupts, analog reading, among other functions. And the pinguino project is very helpful because it takes care of library loading and handful functions.

But in this project I'm working on (reading voltage and shooting various capacitor banks), I need all these functions, but the bootloading interfers with ISIS simulator (with the usb connection), and once the physical circuit has been made, we would not need the bootloading capability anymore.

So I was thinking, could be an option for pinguino to not integrate the bootloader into the output HEX file (to burn it later manually with a programmer)? or, how can I compile pinguino code into a HEX file without the bootloader? (compiling manually with sdcc, for example, but what code must be removed?)

By the way, thank you for making pinguino project open source! I'm reading the python scripts but I don't know how to start.

Thank you in advance!

Reply
12-10-2011, 06:27 AM,
#3
RE: Disable bootloader on compilation
Thanks for your answer. I'm using the 8 bit board, compiling code for a 18f4550 microcontroller. But I'm a little bit confused about the instructions, could you help me with this?

1.- 18f4550.lkr exists in ./lkr/ and ./tools/share/gputils/lkr/ . The file I must replace with the original one (provided by sdcc), I think is the first one (because it contains the "NAME=appli" line that protects the bootloader) , but both files are different of the original one (provided by sdcc [gputils, actually]). Both files must be replaced?

2.- "/obj/crt0ipinguino.o" line must be replaced with "/tools/share/sdcc/lib/pic16/crt0i.o", I think.

3.- The "application_iface.o" line must be removed.

Doing these steps, results in a linking error:

Code:
error: missing definition for symbol "_main", required by "/home/otamay/GIF/Carga_Capacitores/pinguino/PIC/pinguino_beta9-05_linux/tools/share/sdcc/lib/pic16/crt0i.o"

Error mientras enlaza/home/otamay/GIF/Carga_Capacitores/pinguino/PIC/usbprocessing.o

How this can be fixed =/?

Thank you very much for your support!

----EDIT----

source/main.c file must be edited. The function "main()" has been renamed to "pinguino_main()" in order to work with the custom crt0ipinguino.o library. To use the generic crt0i.o library, "pinguino_main()" function must be renamed to "main()" again.

I will test a program using the usb in the simulator. I will post the results later. Jean-Pierre, thank you one more time.
Reply
18-10-2011, 12:08 AM,
#4
RE: Disable bootloader on compilation
Greetings!

I've successfully compiled some examples without the bootloader and loading them on Proteus ISIS simulator, working as expected (well, I've a problem with the delay function and some stack overflows).

However, examples including USB communication doesn't work. I'm using original lkr files but I have no success with the USB recognition when the device is virtually connected to the PC through ISIS simulator. Loading the bootloader (bootloaderV2.12.hex) works as expected, but the standalone application does not. I'm using the usbprocessing.pde example.

Any help will be greatly appreciated.
Reply
21-10-2011, 06:58 AM,
#5
RE: Disable bootloader on compilation
I think the problem is that USB is not initialized. In the bootloader code (boot_main.c), there are some functions to do it:

Code:
void main(void)
{
    unsigned char appvalid;
    ulong i=600000;
    
    TRISA=TRISA&0xEF;
    PORTAbits.RA4=1;
    init_boot();
    init_usb(); // THIS IS THE FUNCTION, I THINK

    while(1)
    {
        usb_sleep();
        dispatch_usb_event();

        if((application_data.invalid == 0)||(application_data.invalid == 1))
        {
        i--;
        if (i==0)
                {
                TRISA=TRISA&0xEF;
                PORTAbits.RA4=0;
                    application_data.main();
                while (1);
                }
        }
    }
}

But if I manually include that function (extrated from usb.c included in the bootloader sources), results in a stack overflow, resetting the device. If instead I use EnableUSBModule() function from picUSB.c (including it before, and removing usb.h including to avoid variable redefinitions), the compilation process ends with a lot of errors.

So I don't know how can I initialize the USB by myself. Anyone have a clue of how doing this?

Thank you in advance.
Reply
22-10-2011, 10:32 PM,
#6
RE: Disable bootloader on compilation
Hi,

USB bulk functions can not be used in a stand alone program ( without the bootloader ). Most of the functions are using some code of the bootloader ( only for USB ). If you want to use USB, instead of using bulk function, use CDC function.
CDC has been completely rewritten and don't use any common code with the bootloader.

Jean-Pierre

(21-10-2011, 06:58 AM)Otamay Wrote: I think the problem is that USB is not initialized. In the bootloader code (boot_main.c), there are some functions to do it:

Code:
void main(void)
{
    unsigned char appvalid;
    ulong i=600000;
    
    TRISA=TRISA&0xEF;
    PORTAbits.RA4=1;
    init_boot();
    init_usb(); // THIS IS THE FUNCTION, I THINK

    while(1)
    {
        usb_sleep();
        dispatch_usb_event();

        if((application_data.invalid == 0)||(application_data.invalid == 1))
        {
        i--;
        if (i==0)
                {
                TRISA=TRISA&0xEF;
                PORTAbits.RA4=0;
                    application_data.main();
                while (1);
                }
        }
    }
}

But if I manually include that function (extrated from usb.c included in the bootloader sources), results in a stack overflow, resetting the device. If instead I use EnableUSBModule() function from picUSB.c (including it before, and removing usb.h including to avoid variable redefinitions), the compilation process ends with a lot of errors.

So I don't know how can I initialize the USB by myself. Anyone have a clue of how doing this?

Thank you in advance.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)