BusPirate / Bus_Pirate

Community driven firmware and hardware for Bus Pirate version 3 and 4
630 stars 132 forks source link

Test the build on a real v3 board #7

Closed agatti closed 7 years ago

agatti commented 8 years ago

Now that the firmware can build for v3, it would be nice to know whether it actually works or not. Unfortunately I only have a v4 board here...

USBEprom commented 7 years ago

@agatti

Thank you sir, I get it now. So I have changed lines 304-319 into configuration.h for setting the features I want.

ifdef BUSPIRATEV3

undef BP_ENABLE_1WIRE_SUPPORT

undef BP_ENABLE_BASIC_SUPPORT

undef BP_ENABLE_DIO_SUPPORT

undef BP_ENABLE_HD44780_SUPPORT

define BP_ENABLE_I2C_SUPPORT

define BP_ENABLE_JTAG_SUPPORT

undef BP_ENABLE_PIC_SUPPORT

undef BP_ENABLE_PC_AT_KEYBOARD_SUPPORT

undef BP_ENABLE_RAW_2WIRE_SUPPORT

undef BP_ENABLE_RAW_3WIRE_SUPPORT

undef BP_ENABLE_SMPS_SUPPORT

define BP_ENABLE_SPI_SUPPORT

define BP_ENABLE_SUMP_SUPPORT

define BP_ENABLE_UART_SUPPORT

endif /* BUSPIRATEV3 */

I changed the line 405 too in this way

define BP_BASIC_PROGRAM_SPACE 512

in order to make room for BASIC scripting.

Finally I changed line 523 from

define BP_COMMAND_BUFFER_SIZE 128

to

define BP_COMMAND_BUFFER_SIZE 256

in order to get up 256 characters for the command line. While compiling I get these messages

"F:\MPLABX\XC16\bin\xc16-gcc.exe" ../spi.c -o build/BusPirate_v3/production/_ext/1472/spi.o -c -mcpu=24FJ64GA002 -MMD -MF "build/BusPirate_v3/production/_ext/1472/spi.o.d" -g -omf=elf -DXPRJ_BusPirate_v3=BusPirate_v3 -no-legacy-libc -mlarge-code -mlarge-data -Os -I"../../microchip/include" -I".." -I"../translations" -msmart-io=1 -Werror -Wall -msfr-warn=off -save-temps "F:\MPLABX\XC16\bin\xc16-gcc.exe" ../uart.c -o build/BusPirate_v3/production/_ext/1472/uart.o -c -mcpu=24FJ64GA002 -MMD -MF "build/BusPirate_v3/production/_ext/1472/uart.o.d" -g -omf=elf -DXPRJ_BusPirate_v3=BusPirate_v3 -no-legacy-libc -mlarge-code -mlarge-data -Os -I"../../microchip/include" -I".." -I"../translations" -msmart-io=1 -Werror -Wall -msfr-warn=off -save-temps ../openocd.c:11:29: fatal error: bus_pirate_core.h: No such file or directory compilation terminated. make[2]: * [build/BusPirate_v3/production/_ext/1472/openocd.o] Error 255 make[1]: * [.build-conf] Error 2 make: *\ [.build-impl] Error 2 "F:\MPLABX\XC16\bin\xc16-gcc.exe" ../openocd.c -o build/BusPirate_v3/production/_ext/1472/openocd.o -c -mcpu=24FJ64GA002 -MMD -MF "build/BusPirate_v3/production/_ext/1472/openocd.o.d" -g -omf=elf -DXPRJ_BusPirate_v3=BusPirate_v3 -no-legacy-libc -mlarge-code -mlarge-data -Os -I"../../microchip/include" -I".." -I"../translations" -msmart-io=1 -Werror -Wall -msfr-warn=off -save-temps nbproject/Makefile-BusPirate_v3.mk:464: recipe for target 'build/BusPirate_v3/production/_ext/1472/openocd.o' failed make[2]: Leaving directory 'F:/MPLAB/Bus_Pirate-master_12112016/Bus_Pirate-master/Firmware/busPirate.X' nbproject/Makefile-BusPirate_v3.mk:84: recipe for target '.build-conf' failed make[1]: Leaving directory 'F:/MPLAB/Bus_Pirate-master_12112016/Bus_Pirate-master/Firmware/busPirate.X' nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

and the operation fails. What is wrong? I guess I am doing something bad but I am babo and I do not know what.

Also I know I am boring a lot, but I took a look inside configuration.h and I do not understand where are the messages related to speeds coded into spi.c. Thanks.

agatti commented 7 years ago

I fixed the build error with https://github.com/BusPirate/Bus_Pirate/commit/4f44d0883afa4d1ad3f8d6de1bcc4c27a2e17422, thanks for noticing.

If you want to reorder the SPI bus speeds, you have to edit the string files in tools/packstrings/bus_pirate_v?_strings.txt, regenerate the messages_v?.h/messages_v?.s running the python script in tools/packstrings, overwrite the message files in the Firmware directory with what you just generated, then you need to reorder the entries in spi_bus_speed inside Firmware/spi.c. If you want to add more, things get a bit more complicated, and there are limits on how many speeds you can add before breaking the binary serial I/O protocol.

USBEprom commented 7 years ago

@agatti

Thank you very much sir, now it work!

http://dangerousprototypes.com/forum/viewtopic.php?f=28&t=8498&start=45#p65526

Thanks also for the explanations about what I asked. These informations are useful to me because I am trying to figure out the matter so I can fend for myself without disturbing anyone.

USBEprom commented 7 years ago

https://github.com/BusPirate/Bus_Pirate/issues/32

agatti commented 7 years ago

@USBEprom can you please create a new issue for this? I'm going to close this one as it is no longer for "test firmware on v3" anymore.

USBEprom commented 7 years ago

@agatti

Sorry sir. You are right. I edited my previous post. I hope I have added the new issue in the proper way. Apologize for having put it in the wrong place. Thanks.

elsni commented 7 years ago

Just bought a new BP 3.6. It has Firmware v5.10 preinstalled, but unfortunately it has no JTAG support, so I need to flash a different one.

After following a bunch of red herring links wasting almost an hour, I finally managed to find pirate-loader and the 7.0 fw hex files for download.

Unfortunately I can't flash the fw. pirate-loader tells me "Checksum does not match, line 4" on every hex file. Converting an hex file to uppercase makes no difference. What am I doing wrong? Thanks for any advice!

agatti commented 7 years ago

@elsni can you please let us know which OS you're using and whether you built the pirate-loader binary yourself from this source code repo or if you're using a pre-built version that came with older firmware packages?

USBEprom commented 7 years ago

@elsni

Do you mean also the factory ones by writing "on every hex file"? The factory firmwares should already be in the correct format without any need of having to convert them, then at least those should work without problems. What do you use to convert the hexadecimal content? What is the operating system you are using?

elsni commented 7 years ago

Hi, Thank you @agatti and @USBEprom for quick reply! At first I used Windows 10 and the precompiled binary from /jevinskie/bus-pirate and the hex files in that repository. I tried again on my kubuntu machine but I compiled pirate-loader from source. That worked, I managed to flash fw 6.3 successfully from a hex file in that repository. I did not convert any binary file to hex by myself. Unfortunately that version of 6.3 does not have jtag support either. Which one can I use?

USBEprom commented 7 years ago

Hi elsni. It is weird that the firmware you have used (https://github.com/jevinskie/bus-pirate) does not support JTAG. This because here:

http://dangerousprototypes.com/docs/Bus_Pirate#JTAG

it said that 6.0 and 6.1 firmwares do contain JTAG terminal mode, hence they have the binary JTAG mode. However take a look at these:

http://dangerousprototypes.com/docs/Bus_Pirate_firmware_change_history

May be you must compile yourself the source in order to build your own firmware. If for any reason you can not do that, try these that are ready to use:

http://dangerousprototypes.com/forum/viewtopic.php?f=4&t=8637#p65660

I do not know if at least one of them allows for JTAG support because I have not seen their configuration setup. Unfortunately, for what I have read, these repositories do not use configuration.h but something else to switch active features so I can not build from them new firmwares where the JTAG support is active.

pixeldoc2000 commented 7 years ago

Hey, i've tested Community Firmware v7.0 on my BusPirate v3b.

Hardware: BusPirate v3b Bootloader: v4.3 OS: Windows 7 x64

pirate-loader.exe from https://github.com/mikebdp2/Bus_Pirate/tree/master/BPv3-bootloader/v4xtov43-bootloader-update/utilities/pirate-loader.exe

Firmware Files

bpv3_fw7.0_opt0_18092016.hex bpv3_fw7.0_opt1_18092016.hex bpv3_fw7.0_opt2_18092016.hex bpv3_fw7.0_optS_18092016.hex

I've converted the Firmware Files to uppercase with to_upper.bat to be able to use pirate-loader.exe . Without conversion pirate-loader.exe does not like the Firmware File with lowercase (Checksum does not match, line 4 , Could not load HEX file, result=-1).

D:\BusPirate>pirate-loader.exe --dev=COM16 --hex=bpv3_fw7.0_opt0_18092016_uppercase.hex
+++++++++++++++++++++++++++++++++++++++++++
  Pirate-Loader for BP with Bootloader v4+
  Loader version: 1.0.2  OS: WINDOWS
+++++++++++++++++++++++++++++++++++++++++++

Parsing HEX file [bpv3_fw7.0_opt0_18092016_uppercase.hex]
Found 18579 words (55737 bytes)
Fixing bootloader/userprogram jumps
Opening serial device COM16...OK
Configuring serial port settings...OK
Sending Hello to the Bootloader...OK

Device ID: PIC24FJ64GA002 [d4]
Bootloader version: 1,02
Erasing page 0, 0000...OK
Writing page 0 row 0, 0000...OK
Writing page 0 row 1, 0080...OK
Writing page 0 row 2, 0100...OK
Writing page 0 row 3, 0180...OK
Writing page 0 row 4, 0200...OK
Writing page 0 row 5, 0280...OK
Writing page 0 row 6, 0300...OK
Writing page 0 row 7, 0380...OK
Erasing page 1, 0400...OK
Writing page 1 row 8, 0400...OK
Writing page 1 row 9, 0480...OK
Writing page 1 row 10, 0500...OK
Writing page 1 row 11, 0580...OK
Writing page 1 row 12, 0600...OK
Writing page 1 row 13, 0680...OK
Writing page 1 row 14, 0700...OK
Writing page 1 row 15, 0780...OK
Erasing page 2, 0800...OK
...
...
...
Writing page 41 row 328, a400...OK
Writing page 41 row 329, a480...OK
Writing page 41 row 330, a500...OK
Writing page 41 row 331, a580...OK
Writing page 41 row 332, a600...OK
Writing page 41 row 333, a680...OK
Writing page 41 row 334, a700...OK
Writing page 41 row 335, a780...OK
Erasing page 42, a800...ERROR [50]

Error updating firmware :(

All Firmware Versions work, besides the bootloader protection error (ERROR [50]).

Test Results for all Firmware Versions are the same

HiZ>i
Bus Pirate v3.b
Community Firmware v7.0 - goo.gl/gCzQnW [HiZ UART I2C SPI] Bootloader v4.3
DEVID:0x0447 REVID:0x3043 (24FJ64GA002 B5)
http://dangerousprototypes.com
HiZ>~
Disconnect any devices
Connect (Vpu to +5V) and (ADC to +3.3V)
Space to continue
Ctrl
AUX OK
MODE LED OK
PULLUP H OK
PULLUP L OK
VREG OK
ADC and supply
5V(5.18) OK
VPU(5.17) OK
3.3V(3.40) OK
ADC(3.43) OK
Bus high
MOSI OK
CLK OK
MISO FAIL
CS OK
Bus Hi-Z 0
MOSI FAIL
CLK OK
MISO OK
CS OK
Bus Hi-Z 1
MOSI OK
CLK OK
MISO FAIL
CS OK
MODE and VREG LEDs should be on!     <--- OK
Any key to exit
Found 3 errors.

$ (Jump to bootloader) command does work
s (Script engine) does not work, it provides a "Syntax error at char 1" message
# (Reset the BP) does work and it shows the message "RESET"

Why does MISO Test fail ?

EDIT: Looks like i've damaged the PIC24FJ64GA002 MCU of my BPv3 at my last adventure. MOSI is always HIGH and MISO is always LOW no matter what.

USBEprom commented 7 years ago

Hi pixeldoc2000. First thanks for reporting Community Firmware v7.0 on a real BusPirate v3b. Unfortunately your Bus Pirate could be really broken. In order to troubleshoot the problem you can chase it doing what it is explain here:

http://dangerousprototypes.com/forum/viewtopic.php?f=4&t=7047

Basically you can test all the pins of your Bus Pirate for short circuit, cold welds or any else fault.

pixeldoc2000 commented 7 years ago

Hi @USBEprom. i already did some hardware tests: http://dangerousprototypes.com/docs/Bus_Pirate_self-test_guide

EDIT: Looks like i've damaged the PIC24FJ64GA002 MCU of my BPv3 at my last adventure. MOSI is always HIGH and MISO is always LOW no matter what.

I've bought a BPv4 as a replacement for my broken BPv3 because I really like the BP Conecpt and the new Community Firmware effords.

ttelford commented 7 years ago

Update from my testing:

I'm only testing the current set of binaries; I don't have time at the moment to get the dev stack installed to build the latest from it.

I have the BPv3.6 hardware

Each hex ends badly - and identically.

bpv3_fw7.0_opt0_18092016.hex

Erasing page 42, a800...ERROR [50]
Error updating firmware :(

bpv3_fw7.0_opt1_18092016.hex Erasing page 42, a800...ERROR [50] Error updating firmware :(

bpv3_fw7.0_opt2_18092016.hex Erasing page 42, a800...ERROR [50] Error updating firmware :(

bpv3_fw7.0_optS_18092016.hex Erasing page 42, a800...ERROR [50] Error updating firmware :(

Downgrading to 6.1 works - though it doesn't attempt to write page 42.

I haven't updated the boot loader - perhaps that may be involved?

Device ID: PIC24FJ64GA002 [d4]
Bootloader version: 1,02
USBEprom commented 7 years ago

@ ttelford

Hi ttelford. Actually that error message does not mean that something is wrong with the firmware. More than a matter of bootloader it is a issue with pirate-loader or related tools. Please read here:

http://dangerousprototypes.com/forum/viewtopic.php?f=28&t=8498&start=15

and especially these with careful:

http://dangerousprototypes.com/forum/viewtopic.php?f=28&t=8498&start=15#p65317

https://github.com/BusPirate/Bus_Pirate/issues/7#issuecomment-248103673

If something is not wrong

ttelford wrote:

Bootloader version: 1,02

It is very old. First you must upgrade it in order to upgrade firmware in the right way.

I guess there is a typo in here.

ttelford wrote:

Device ID: PIC24FJ64GA002 [d4]

Silicon revision d4 does not exist:

http://ww1.microchip.com/downloads/en/DeviceDoc/80000470h.pdf

(follow up: http://dangerousprototypes.com/forum/viewtopic.php?f=4&t=8650#p65737)

ttelford commented 7 years ago

Bootloader version: 1,02 Device ID: PIC24FJ64GA002 [d4]

Silicon revision d4 does not exist:

Not a typo in either case. It's a direct copy/paste.

Still, nice to know The path forward.

USBEprom commented 7 years ago

@ ttelford

About what you wrote "Bootloader version: 1,02", seems it is the ds30 loader version, not your own version of the bootloader. Look here:

http://dangerousprototypes.com/forum/viewtopic.php?f=4&t=703&p=6862#p6480

About the silicon revision [d4] (Device ID: PIC24FJ64GA002 [d4]) actually you are right, I did not knew it.

ttelford commented 7 years ago

Perhaps a bit more about my hardware (and software) is in order:

I've been using pirate-loader exclusively, on either Linux or OS X (whichever is close to me a the time...) Does ds30 share code with pirate-loader?

I also managed to get a hold of a second, "brand new" (2015 manufacture) Bus Pirate 3.5.

Both of my Bus Pirate 3's currently report the following:

HiZ>i
Bus Pirate v3.5
Firmware v6.1 r1676  Bootloader v4.4
DEVID:0x0447 REVID:0x3046 (24FJ64GA002 B8)
http://dangerousprototypes.com

I'm still seeing the exact same error I reported above with the new firmware images.

On a side note: My single Bus Pirate v4 updated to the new release just fine.

USBEprom commented 7 years ago

@ ttelford

The message you wrote

ttelford wrote:

HiZ>i Bus Pirate v3.5 Firmware v6.1 r1676 Bootloader v4.4 DEVID:0x0447 REVID:0x3046 (24FJ64GA002 B8) http://dangerousprototypes.com

is totally right. As I already wrote you must just ignore the message of error, it is not a real issue. I do not know if ds30 does share code with pirate-loader, sorry. I know the issue is not into the bootloader or the firmware for sure. The issue do not plagues the Bus Pirate revision 4, so what you wrote is just what is expected. https://github.com/BusPirate/Bus_Pirate/issues/26#issuecomment-260239782 So in the end the silicon revision of your devices actually is B8, not D4.

USBEprom commented 7 years ago

Some doubts. as agatti wrote: https://github.com/BusPirate/Bus_Pirate/issues/7#issuecomment-258251235 I was able to build my own version of the firmware for the Bus Pirate v3 where all the features are unlocked, BASIC too (dangerousprototypes.com/forum/download/file.php?id=12196). In order to reach the goal among the other things I had to switch #define PGMSIZE 1024 to #define PGMSIZE 512. I do not understand some things. Today I wanted to verify the exact amount of the space of RAM available in BASIC. Seems to me that factory firmware v5.10 allows up 65535 lines for BASIC. I have downloaded the factory firmware v5.10 into my Bus Pirate revision 3, then I switched to BASIC where I put in a simple sequence of REM in order to evaluate how much room should be avalaible to storage scripts in BASIC. I was able to enter more than 700 program lines occupying 3kB into the RAM, but I could enter other lines apparently without any problem. So apparently by reserving 1024 bytes for the BASIC should be possible to enter more than that quantity of bytes, that it sounds weird. Indeed this does not match with the value 1024 that is used into #define PGMSIZE. I have not gone over and I have updated my Bus Pirate with the firmware v7.0 that I built. With it I was able to insert up 128 lines of program which are exactly 511 bytes, I could not go further. This match with the value 512 that I put into #define PGMSIZE. Now I know that although into both the firmwares v5.10 and the v7.0 that I built from myself BASIC was unlocked and command line up to 256 characters, my v7.0 has many unlocked features than v5.10, but I do not understand such a big gap based on using the value 1024 or its half. So my question is, is there some way to predict the exact amount of available space for BASIC by evaluating the features unlocked into the firmware before build it? Honestly I did not expect a real value of 32767 lines (half of 65535 lines), but not even a such big gap:

define PGMSIZE 1024 (factory firmware v5.10) = over 3kB (over 700 lines of REM), I do not even know exactly what it actually is, I have not verified precisely.

define PGMSIZE 512 (firmware v7.0 built by myself) = up 511 bytes (exactly 128 lines of REM), not one more.

Thanks.

agatti commented 7 years ago

Given that we now have users who are trying the firmware on v3 boards, I guess it's time to retire this ticket.

If you have issues related to the community firmware on Bus Pirate v3 boards, please open a new bug if none of the currently open ones match your issue, thank you.

This issue has been closed since months, so please open another issue instead of posting here - it makes management easier.