Shop OBEX P1 Docs P2 Docs Learn Events
Can't Wait for PropGCC on the P2? - Page 10 — Parallax Forums

Can't Wait for PropGCC on the P2?

17810121326

Comments

  • Here's a new version of loadp2.c that incorporates MainLoader1.spin2. It sets up the oscillator, waits 10 ms, and then enables the oscillator. For 80MHz, the mode should be 010c1f04.
  • Dave HeinDave Hein Posts: 6,347
    edited 2018-12-28 23:13
    UPS delivered my board about a half hour ago. I am able to run most of the p2gcc test programs. I'm using the version of loadp2 that I posted in my previous post. I load the programs as follows:
    loadp2 -v -t -m 010c1f08 hello.bin
    
    The mode value of 010c1f08 sets the board to 80MHz so that my serial code runs at the right baud rate. The following programs run without any problems:
    bas chess dry fibo fft_bench hello malloctest prime xxtea test7
    
    The blink program doesn't work correctly, and fsrwtest and filetest do not mount the SD card. I'll look at them to try to figure out what's wrong.
  • Dave HeinDave Hein Posts: 6,347
    edited 2018-12-29 00:18
    The blink program works with P32-P37, which aren't displayed on the P2 Eval board. So it's probably working OK, but I can't see the those bits on the board.

    EDIT: I change blink to us P56-P59, and it's working fine.
  • I'm using the following pins when mounting the SD card.
    59 - DO
    60 - CLK
    58 - DI
    61 - CS
    
    Are these the correct pins for the P2 Eval board?
  • The Eval docs say
    This socket is hardwired to four Propeller 2 I/O pins:
      ● P58 - DI/CD (data in and card detect)
     ● P59 - DO (data out)
     ● P60 - /CS (active low chip select)
    . ● P61 - CLK (clock
    
  • you need to swap cs and clk

    maybe di/do, depending on that code perspective...

    the eval sd card pinout is

    58 ... miso
    59 ... mosi
    60 ... cs
    61 ... clk
  • Still not printing anything in loadp2's terminal. I'm reading from the beginning of the thread to see if I missed anything.

    You uploaded two files above - loadp2.c and MainLoader1.spin2. I don't see any reference to that file throughout the codebase, including in your newly uploaded loadp2.c. Am I missing something there?
  • I had to swap cs and clk, and di and do. Both fsrwtest and filetest work now. Thanks for your help. Now I need to try faster clock speeds.
  • Dave HeinDave Hein Posts: 6,347
    edited 2018-12-29 01:23
    Tried 160MHz by typing
    $ loadp2 -v -t -m 010c3f08 -b 230400 -f 160000000 filetest.bin
    
    That worked fine.

    The loader needs to know the frequency, so the -f option must be used. The C serial driver assumes 80MHz, so the baud rate is proportional to the clock frequency, which is why I had to specify a higher baud rate. Eventually I'll clean this up so that only a clock rate needs to be specified. I should be able to detect FPGA versus silicon so that the mode is set up properly.
  • evanhevanh Posts: 16,032
    DavidZemon wrote: »
    You uploaded two files above - loadp2.c and MainLoader1.spin2. I don't see any reference to that file throughout the codebase, including in your newly uploaded loadp2.c. Am I missing something there?


    This'll be it (In loadp2.c), see last line:
        if (verbose) printf("Loading %s - %d bytes\n", fname, size);
        hwreset();
        msleep(50);
        tx((uint8_t *)"> Prop_Hex 0 0 0 0", 18);
        tx((uint8_t *)MainLoader, strlen(MainLoader));
    

  • evanh wrote: »
    DavidZemon wrote: »
    You uploaded two files above - loadp2.c and MainLoader1.spin2. I don't see any reference to that file throughout the codebase, including in your newly uploaded loadp2.c. Am I missing something there?
    This'll be it (In loadp2.c), see last line:
        if (verbose) printf("Loading %s - %d bytes\n", fname, size);
        hwreset();
        msleep(50);
        tx((uint8_t *)"> Prop_Hex 0 0 0 0", 18);
        tx((uint8_t *)MainLoader, strlen(MainLoader));
    
    The content of a compiled MainLoader1.spin2 is included previously in loadp2.c...
    char *MainLoader =
    #if 0
    " 00 1e 60 fd 13 00 88 fc 20 7e 65 fd 24 08 60 fd 24 28 60 fd 1f 20 60 fd 08 06 dc fc 40 7e 74 fd$
    #else
    " 00 26 60 fd 86 01 80 ff 1f 80 66 fd 03 26 44 f5 00 26 60 fd 17 00 88 fc 20 7e 65 fd 24 08 60 fd$
    #endif
    
  • Still completely lost... nothing is being printed to the console, nor am I seeing the TX/RX lights blinking once the initial programming is complete.
    david@balrog:~/reusable/Documents/Programming/Propeller2/HelloP2GCC$ cat Makefile 
    export PATH := $(PROPGCC_PREFIX)/bin:$(PATH)
    
    run-%: %.bin
            @echo --- LOADING $< ---
            loadp2 -v -t -p /dev/ttyUSB0 -m 010c1f08 $<
    
    %.bin: %.c
            @echo --- COMPILING $< ---
            bash p2gcc -v -o $@ $<
    
    clean:
            rm -f *.o *.bin
    david@balrog:~/reusable/Documents/Programming/Propeller2/HelloP2GCC$ cat hello.c
    #include <stdio.h>
    #include <propeller.h>
    
    void main(void)
    {
        int i;
    
        for (i = 1; i <= 10; i++)
        {
            waitcnt(CNT+12000000);
            printf("Hello World - %d\n", i);
        }
        printf("Goodbye\n");
    }
    david@balrog:~/reusable/Documents/Programming/Propeller2/HelloP2GCC$ make clean run-hello
    rm -f *.o *.bin
    --- COMPILING hello.c ---
    bash p2gcc -v -o hello.bin hello.c
    propeller-elf-gcc -mcog -Os -m32bit-doubles -S hello.c
    s2pasm -p/home/david/reusable/software/p2gcc/lib/prefix.spin2 hello
    p2asm -c -o hello.spin2
    p2link /home/david/reusable/software/p2gcc/lib/prefix.o -v -o hello.bin hello.o /home/david/reusable/software/p2gcc/lib/stdio.a /home/david/reusable/software/p2gcc/lib/stdlib.a /home/david/reusable/software/p2gcc/lib/string.a
    Found offset of 12 for symbol ___files of type 04 at location b14
    --- LOADING hello.bin ---
    loadp2 -v -t -p /dev/ttyUSB0 -m 010c1f08 hello.bin
    Loading hello.bin - 2548 bytes
    hello.bin loaded
    [ Entering terminal mode.  Press ESC to exit. ]
    rm hello.bin
    david@balrog:~/reusable/Documents/Programming/Propeller2/HelloP2GCC$
    

    Maybe I'm doing something wrong when building p2gcc? I tried starting over from scratch:
    david@balrog:~/reusable/software$ git clone https://github.com/davehein/p2gcc.git
    Cloning into 'p2gcc'...
    remote: Enumerating objects: 44, done.
    remote: Counting objects: 100% (44/44), done.
    remote: Compressing objects: 100% (36/36), done.
    remote: Total 735 (delta 14), reused 25 (delta 8), pack-reused 691
    Receiving objects: 100% (735/735), 1.58 MiB | 8.11 MiB/s, done.
    Resolving deltas: 100% (360/360), done.
    david@balrog:~/reusable/software$ cd p2gcc/loadp2_src/
    david@balrog:~/reusable/software/p2gcc/loadp2_src$ rm loadp2.c && wget --quiet https://forums.parallax.com/discussion/download/124912/loadp2.c
    david@balrog:~/reusable/software/p2gcc/loadp2_src$ cd ..
    david@balrog:~/reusable/software/p2gcc$ chmod +x build_linux 
    david@balrog:~/reusable/software/p2gcc$ vim build_linux 
    david@balrog:~/reusable/software/p2gcc$ export PATH=$PROPGCC_PREFIX/bin:$PATH
    david@balrog:~/reusable/software/p2gcc$ ./build_linux 
    ++ chmod +x build_all
    ++ chmod +x test_all
    ++ chmod +x load_shell
    ++ chmod +x lib/buildlibs
    ++ chmod +x p2gcc
    ++ rm -rf bin
    ++ mkdir bin
    ++ cd p2asm_src
    ++ chmod +x buildit
    ++ ./buildit
    ++ cp p2asm ../bin
    ++ cd ..
    ++ cd p2link_src
    ++ gcc p2link.c -o p2link
    ++ cp p2link ../bin
    ++ cd ..
    ++ cd loadp2_src
    ++ chmod +x build_linux
    ++ ./build_linux
    ++ cp loadp2 ../bin
    ++ cd ..
    ++ cd s2pasm_src
    ++ gcc s2pasm.c -o s2pasm
    ++ cp s2pasm ../bin
    ++ cd ..
    ++ cd util
    ++ gcc p2dump.c -o p2dump
    ++ cp p2dump ../bin
    ++ gcc p2dumpobj.c -o p2dumpobj
    ++ cp p2dumpobj ../bin
    ++ chmod +x diffit
    ++ cp diffit ../bin
    ++ cd ..
    ++ cp p2gcc bin
    david@balrog:~/reusable/software/p2gcc$ cd lib/
    david@balrog:~/reusable/software/p2gcc/lib$ ./buildlibs 
    printf
    sprintf
    scanf
    sscanf
    fprintf
    fileio
    fileio.c:23:1: warning: missing braces around initializer [-Wmissing-braces]
    fileio.c:23:1: warning: (near initialization for '__files[0]') [-Wmissing-braces]
    fsrw
    sdspi
    puts
    gets
    getchar
    getch
    putchar
    putch
    exit
    abort
    atol
    atoi
    strtol
    rand
    toupper
    tolower
    sleep
    clock
    ctype
    malloc
    memcpy
    memset
    strcat
    strcmp
    strcpy
    strncpy
    strlen
    strncmp
    david@balrog:~/reusable/software/p2gcc/lib$ cd ..
    david@balrog:~/reusable/software/p2gcc$ l bin
    diffit*  loadp2*  p2asm*  p2dump*  p2dumpobj*  p2gcc*  p2link*  s2pasm*
    david@balrog:~/reusable/software/p2gcc$
    

    Still nothing in loadp2's terminal.
  • dgately wrote: »
    evanh wrote: »
    DavidZemon wrote: »
    You uploaded two files above - loadp2.c and MainLoader1.spin2. I don't see any reference to that file throughout the codebase, including in your newly uploaded loadp2.c. Am I missing something there?
    This'll be it (In loadp2.c), see last line:
        if (verbose) printf("Loading %s - %d bytes\n", fname, size);
        hwreset();
        msleep(50);
        tx((uint8_t *)"> Prop_Hex 0 0 0 0", 18);
        tx((uint8_t *)MainLoader, strlen(MainLoader));
    
    The content of a compiled MainLoader1.spin2 is included previously in loadp2.c...
    char *MainLoader =
    #if 0
    " 00 1e 60 fd 13 00 88 fc 20 7e 65 fd 24 08 60 fd 24 28 60 fd 1f 20 60 fd 08 06 dc fc 40 7e 74 fd$
    #else
    " 00 26 60 fd 86 01 80 ff 1f 80 66 fd 03 26 44 f5 00 26 60 fd 17 00 88 fc 20 7e 65 fd 24 08 60 fd$
    #endif
    

    Thanks - that makes sense now.
  • DavidZemon wrote: »
    dgately wrote: »
    evanh wrote: »
    DavidZemon wrote: »
    You uploaded two files above - loadp2.c and MainLoader1.spin2. I don't see any reference to that file throughout the codebase, including in your newly uploaded loadp2.c. Am I missing something there?
    This'll be it (In loadp2.c), see last line:
        if (verbose) printf("Loading %s - %d bytes\n", fname, size);
        hwreset();
        msleep(50);
        tx((uint8_t *)"> Prop_Hex 0 0 0 0", 18);
        tx((uint8_t *)MainLoader, strlen(MainLoader));
    
    The content of a compiled MainLoader1.spin2 is included previously in loadp2.c...
    char *MainLoader =
    #if 0
    " 00 1e 60 fd 13 00 88 fc 20 7e 65 fd 24 08 60 fd 24 28 60 fd 1f 20 60 fd 08 06 dc fc 40 7e 74 fd$
    #else
    " 00 26 60 fd 86 01 80 ff 1f 80 66 fd 03 26 44 f5 00 26 60 fd 17 00 88 fc 20 7e 65 fd 24 08 60 fd$
    #endif
    
    Thanks - that makes sense now.
    I've only gotten loadp2 to work on a Win 10 VM... And, only to load binaries that were built by PNut. I still need to test (on Win 10) loading binaries built from fastspin, with the most-recent notes about setting mode & frequency as loadp2 params...

    Have not been able to use loadp2 successfully on Linux or macOS, so far.
  • dgately wrote: »
    I've only gotten loadp2 to work on a Win 10 VM... And, only to load binaries that were built by PNut. I still need to test (on Win 10) loading binaries built from fastspin, with the most-recent notes about setting mode & frequency as loadp2 params...

    Have not been able to use loadp2 successfully on Linux or macOS, so far.

    dgately,

    I also need to get loadp2 working on ubuntu natively.

    You may want to read my post in P2 Newbie Discussion (about 30 mins ago), may solve your problem.

  • evanhevanh Posts: 16,032
    edited 2018-12-29 10:43
    Oh yeah, have to add yourself to dialout group.
  • I tried loadp2 on my ubuntu system, and it doesn't work for me either. I tried changing wait times, and I fiddled with the hwreset routine, but it still doesn't run.

    I was also hoping to detect between the FPGA version and the silicon version, but it appears that they both return Prop_Ver A. Is there anyway to distinguish between the two?
  • avsa242avsa242 Posts: 452
    edited 2018-12-29 15:58
    @"Dave Hein"

    Just curious, re: your last post...what system were you running on in the previous posts in this thread, where you were able to successfully load? The $ prompt gives the impression it was unix-like?

    Thanks,
    Jesse
  • Dave HeinDave Hein Posts: 6,347
    edited 2018-12-29 18:17
    I was running under Cygwin. In theory, the code should compile fine under MinGW and run under Windows. I generally don't test out MinGW/Windows until I'm ready to send out an exe file.

    I'll be posting an update soon with Windows executables once I finished adding some changes to loadp2 so it supports both the FPGA and the P2 silicon.
  • jmgjmg Posts: 15,175
    Dave Hein wrote: »
    I was also hoping to detect between the FPGA version and the silicon version, but it appears that they both return Prop_Ver A. Is there anyway to distinguish between the two?
    That seems an oversight, should be easy to fix on next steps.
    TAQOZ takes 240ms to enable, so that's a bit slow for checks.
    There is the Prop_Clk command - what does that do different on FPGA vs Silicon ? IIRC it is only 2 choices 20M/80M on FPGA ?

    So maybe switch to rcslow, and then '> Prop_Ver... - a reply at high baud rates is FPGA ?
  • @DavidZemon has two versions of PropGcc on his Buildserver. GCC4 and GCC5.

    Which one I should install to use P2gcc on a P2-EVAL?

    Mike
  • msrobots wrote: »
    @DavidZemon has two versions of PropGcc on his Buildserver. GCC4 and GCC5.

    Which one I should install to use P2gcc on a P2-EVAL?

    Mike

    Please keep in mind that "GCC5" actually refers to GCC6 now... I'm avoiding a rename because I don't want a million links that are spread across the forums to suddenly stop working.
  • Either version should work with p2gcc, since it just converts the P1 ASM code to P2 code. If it works for P1 it should work for P2.
  • Dave HeinDave Hein Posts: 6,347
    edited 2018-12-29 20:50
    Dave Hein wrote: »
    I was also hoping to detect between the FPGA version and the silicon version, but it appears that they both return Prop_Ver A. Is there anyway to distinguish between the two?
    I was wrong about the version returned by the FPGA. It returns version B. So I can auto-detect FPGA versus silicon. I've already modified loadp2 to allow specifying FPGA or silicon. So I'll change it to use the version, and an option can be used to override it.

    So now the only thing that needs to be specified is the clock frequency. loadp2 will then generate the appropriate mode value and user baud rate. If the clock rate isn't specified it will default to 80MHz. So a load command can be as simple as
    loadp2 -t hello.bin
    
    and the loader will detect FPGA versus silicon, and generate the correct clock mode and user baud rate. I've also added a -SINGLE option that will use a single stage loader. The user program will have to configure the clock itself.

  • OK, thank you

    I then will install gcc5 from @DavidZemon which is gcc6 and hopefully the version used to start P2 work on.

    There is something irritating me, why 80Mhz?

    The FPGA did run at 80Mhz, but the silicon starts at RCFAST, so ~18-23Mhz and can go way faster as the FPGA.

    Pnut tells me that my EVAL runs at 80Mhz. Why? Shouldn't Version B show 80Mhz but Version A (the silicon) show something like 120 or 180 or even 360?

    confused

    Mike
  • 80 megahertz seems like maybe a baseline speed. That's what a lot of P1 chips run at.
  • jmgjmg Posts: 15,175
    Dave Hein wrote: »
    Dave Hein wrote: »
    I was also hoping to detect between the FPGA version and the silicon version, but it appears that they both return Prop_Ver A. Is there anyway to distinguish between the two?
    I was wrong about the version returned by the FPGA. It returns version B. So I can auto-detect FPGA versus silicon.


    That's easier.
    Thinking ahead, should the next FPGA return version C (as it is quite different in features), and then next silicon rev reports Version D, so the software checks work across all releases.

  • jmgjmg Posts: 15,175
    msrobots wrote: »
    OK, thank you

    I then will install gcc5 from @DavidZemon which is gcc6 and hopefully the version used to start P2 work on.

    There is something irritating me, why 80Mhz?

    The FPGA did run at 80Mhz, but the silicon starts at RCFAST, so ~18-23Mhz and can go way faster as the FPGA.

    Pnut tells me that my EVAL runs at 80Mhz. Why? Shouldn't Version B show 80Mhz but Version A (the silicon) show something like 120 or 180 or even 360?

    confused

    Mike

    That's just software catching up.
    FPGA was 20 / 80 MHz so that was where all software testing was done, and how SW was coded.
    Now real P2 silicon exists, the SW has to catch up to the various XTALS and Boards, and allow users to define the clock settings.
  • But putting a '80Mhz' there makes no sense. P2 was projected at 120 (160?) and is running even faster. The 80 is a remainder of the FPGA and has nothing to do with the actual silicon.

    So again why 80?

    Mike
  • I don't know why PNut shows 80MHz, but it is the default for loadp2. A program that was developed for the FPGA can run without change on the silicon at 80MHz. Of course, the silicon can run at faster speeds, but a lot of code can be checked out at 80MHz to make sure it is logically correct.
Sign In or Register to comment.