Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Compile Bootloader for Microchip MZ Starter Kit USB #44

Open
davidbitton opened this issue Feb 8, 2018 · 45 comments
Open

Unable to Compile Bootloader for Microchip MZ Starter Kit USB #44

davidbitton opened this issue Feb 8, 2018 · 45 comments

Comments

@davidbitton
Copy link

I cloned the UART MPLAB config and changed the capabilities in microchip.hto blCapUSBInterface. In looking at the build output for a Fubarino SD USB, I see cdccam.o. Do I need to make further changes to the MPLAB config for the M7 board to include the necessary USB code? Thanks!


CLEAN SUCCESSFUL (total time: 59ms)
make -f nbproject/Makefile-MICROCHIP_MZ_STARTER_KIT_USB.mk SUBPROJECTS= .build-conf
make[1]: Entering directory '/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/chipKIT-Bootloaders.X'
make  -f nbproject/Makefile-MICROCHIP_MZ_STARTER_KIT_USB.mk dist/MICROCHIP_MZ_STARTER_KIT_USB/production/chipKIT-Bootloaders.X.production.hex
make[2]: Entering directory '/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/chipKIT-Bootloaders.X'
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -c -mprocessor=32MZ2048EFM144 -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_cache.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_cache.o ../pic32_init_cache.S -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder -Wa,--defsym=__MPLAB_BUILD=1,-MD=build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_cache.o.asm.d,--gdwarf-2 -DPIC32MZ -DINIT_MMU_MZ_FIXED -DINIT_SSX -DINIT_L1_CACHE -DINIT_DSPR2 -DPIC32_SRS_SET_COUNT=8 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -c -mprocessor=32MZ2048EFM144 -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0MZ.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0MZ.o ../crt0MZ.S -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder -Wa,--defsym=__MPLAB_BUILD=1,-MD=build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0MZ.o.asm.d,--gdwarf-2 -DPIC32MZ -DINIT_MMU_MZ_FIXED -DINIT_SSX -DINIT_L1_CACHE -DINIT_DSPR2 -DPIC32_SRS_SET_COUNT=8 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -c -mprocessor=32MZ2048EFM144 -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_tlb_ebi_sqi.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_tlb_ebi_sqi.o ../pic32_init_tlb_ebi_sqi.S -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder -Wa,--defsym=__MPLAB_BUILD=1,-MD=build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_tlb_ebi_sqi.o.asm.d,--gdwarf-2 -DPIC32MZ -DINIT_MMU_MZ_FIXED -DINIT_SSX -DINIT_L1_CACHE -DINIT_DSPR2 -DPIC32_SRS_SET_COUNT=8 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -g -x c -c -mprocessor=32MZ2048EFM144 -D_BOARD_MICROCHIP_ETH_START_KIT_USB_ -I.. -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o ../main.c -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc"   -mprocessor=32MZ2048EFM144 -nostdlib -nostartfiles -mno-float -o dist/MICROCHIP_MZ_STARTER_KIT_USB/production/chipKIT-Bootloaders.X.production.elf build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0MZ.o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_cache.o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_tlb_ebi_sqi.o          -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB  -no-legacy-libc  -ftoplevel-reorder   -Wl,--defsym=__MPLAB_BUILD=1,--script="../MZ-boot-linkerscript.ld",--no-code-in-dinit,--no-dinit-in-serial-mem,-Map="dist/MICROCHIP_MZ_STARTER_KIT_USB/production/chipKIT-Bootloaders.X.production.map",--memorysummary,dist/MICROCHIP_MZ_STARTER_KIT_USB/production/memoryfile.xml
nbproject/Makefile-MICROCHIP_MZ_STARTER_KIT_USB.mk:198: recipe for target 'dist/MICROCHIP_MZ_STARTER_KIT_USB/production/chipKIT-Bootloaders.X.production.hex' failed
build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o: In function `usb_print':
make[2]: Leaving directory '/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/chipKIT-Bootloaders.X'
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/BoardConfig.h:673: undefined reference to `cdcacm_attached'
nbproject/Makefile-MICROCHIP_MZ_STARTER_KIT_USB.mk:103: recipe for target '.build-conf' failed
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/BoardConfig.h:673: undefined reference to `cdcacm_active'
make[1]: Leaving directory '/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/chipKIT-Bootloaders.X'
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/BoardConfig.h:674: undefined reference to `cdcacm_print'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o: In function `ExecuteApp':
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/main.c:631: undefined reference to `usb_uninitialize'
build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o: In function `InitStk500v2Interface':
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/BoardConfig.h:666: undefined reference to `usb_initialize'
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/BoardConfig.h:667: undefined reference to `null_reset_cbfn'
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/BoardConfig.h:667: undefined reference to `null_reset_cbfn'
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/BoardConfig.h:667: undefined reference to `cdcacm_register'
build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o: In function `main':
/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/main.c:229: undefined reference to `usb_isr'
collect2: error: ld returned 255 exit status
make[2]: *** [dist/MICROCHIP_MZ_STARTER_KIT_USB/production/chipKIT-Bootloaders.X.production.hex] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 575ms)
@davidbitton
Copy link
Author

A little more research, and I do see a difference amongst the project files. For example, this is for the Fubarino SD USB:

menubar_and_mplab_x_ide_v4_10_-_chipkit-bootloaders___fubarino_sd_usb

Where as the Microchip board is:

menubar_and_mplab_x_ide_v4_10_-_chipkit-bootloaders___microchip_mz_starter_kit_usb

So I think I answered my own question, but is this all the necessary changes to go from UART to USB?

@EmbeddedMan
Copy link
Member

EmbeddedMan commented Feb 8, 2018 via email

@davidbitton
Copy link
Author

@EmbeddedMan I'm making "progress". I [en|dis]abled the USB and Serial files, and now I have this build output. From the looks of it, I'm missing a lib.


CLEAN SUCCESSFUL (total time: 52ms)
make -f nbproject/Makefile-MICROCHIP_MZ_STARTER_KIT_USB.mk SUBPROJECTS= .build-conf
make[1]: Entering directory '/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/chipKIT-Bootloaders.X'
make  -f nbproject/Makefile-MICROCHIP_MZ_STARTER_KIT_USB.mk dist/MICROCHIP_MZ_STARTER_KIT_USB/production/chipKIT-Bootloaders.X.production.hex
make[2]: Entering directory '/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/chipKIT-Bootloaders.X'
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -c -mprocessor=32MZ2048EFM144 -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0.o ../crt0.S -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder -Wa,--defsym=__MPLAB_BUILD=1,-MD=build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0.o.asm.d,--gdwarf-2 -DPIC32MZ -DINIT_MMU_MZ_FIXED -DINIT_SSX -DINIT_L1_CACHE -DINIT_DSPR2 -DPIC32_SRS_SET_COUNT=8 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -c -mprocessor=32MZ2048EFM144 -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_tlb_ebi_sqi.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_tlb_ebi_sqi.o ../pic32_init_tlb_ebi_sqi.S -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder -Wa,--defsym=__MPLAB_BUILD=1,-MD=build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_tlb_ebi_sqi.o.asm.d,--gdwarf-2 -DPIC32MZ -DINIT_MMU_MZ_FIXED -DINIT_SSX -DINIT_L1_CACHE -DINIT_DSPR2 -DPIC32_SRS_SET_COUNT=8 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -c -mprocessor=32MZ2048EFM144 -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0MZ.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0MZ.o ../crt0MZ.S -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder -Wa,--defsym=__MPLAB_BUILD=1,-MD=build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/crt0MZ.o.asm.d,--gdwarf-2 -DPIC32MZ -DINIT_MMU_MZ_FIXED -DINIT_SSX -DINIT_L1_CACHE -DINIT_DSPR2 -DPIC32_SRS_SET_COUNT=8 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -c -mprocessor=32MZ2048EFM144 -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_cache.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_cache.o ../pic32_init_cache.S -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder -Wa,--defsym=__MPLAB_BUILD=1,-MD=build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/pic32_init_cache.o.asm.d,--gdwarf-2 -DPIC32MZ -DINIT_MMU_MZ_FIXED -DINIT_SSX -DINIT_L1_CACHE -DINIT_DSPR2 -DPIC32_SRS_SET_COUNT=8 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -g -x c -c -mprocessor=32MZ2048EFM144 -D_BOARD_MICROCHIP_ETH_START_KIT_USB_ -I.. -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/usb.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/usb.o ../usb.c -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder 
nbproject/Makefile-MICROCHIP_MZ_STARTER_KIT_USB.mk:214: recipe for target 'build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/usb.o' failed
../usb.c: In function 'usb_device_wait':
../usb.c:42:26: error: 'U1CON' undeclared (first use in this function)
 #define MCF_USB_OTG_CTL  U1CON
                          ^
../usb.c:220:5: note: in expansion of macro 'MCF_USB_OTG_CTL'
     MCF_USB_OTG_CTL = MCF_USB_OTG_CTL_USB_EN_SOF_EN;
     ^
../usb.c:42:26: note: each undeclared identifier is reported only once for each function it appears in
 #define MCF_USB_OTG_CTL  U1CON
                          ^
../usb.c:220:5: note: in expansion of macro 'MCF_USB_OTG_CTL'
     MCF_USB_OTG_CTL = MCF_USB_OTG_CTL_USB_EN_SOF_EN;
     ^
../usb.c:43:40: error: '_U1CON_SOFEN_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_CTL_USB_EN_SOF_EN  _U1CON_SOFEN_MASK
                                        ^
../usb.c:220:23: note: in expansion of macro 'MCF_USB_OTG_CTL_USB_EN_SOF_EN'
     MCF_USB_OTG_CTL = MCF_USB_OTG_CTL_USB_EN_SOF_EN;
                       ^
../usb.c:44:31: error: 'U1OTGCON' undeclared (first use in this function)
 #define MCF_USB_OTG_OTG_CTRL  U1OTGCON
                               ^
../usb.c:223:5: note: in expansion of macro 'MCF_USB_OTG_OTG_CTRL'
     MCF_USB_OTG_OTG_CTRL = MCF_USB_OTG_OTG_CTRL_DP_HIGH|MCF_USB_OTG_OTG_CTRL_OTG_EN;
     ^
../usb.c:45:39: error: '_U1OTGCON_DPPULUP_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_OTG_CTRL_DP_HIGH  _U1OTGCON_DPPULUP_MASK
                                       ^
../usb.c:223:28: note: in expansion of macro 'MCF_USB_OTG_OTG_CTRL_DP_HIGH'
     MCF_USB_OTG_OTG_CTRL = MCF_USB_OTG_OTG_CTRL_DP_HIGH|MCF_USB_OTG_OTG_CTRL_OTG_EN;
                            ^
../usb.c:46:38: error: '_U1OTGCON_OTGEN_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_OTG_CTRL_OTG_EN  _U1OTGCON_OTGEN_MASK
                                      ^
../usb.c:223:57: note: in expansion of macro 'MCF_USB_OTG_OTG_CTRL_OTG_EN'
     MCF_USB_OTG_OTG_CTRL = MCF_USB_OTG_OTG_CTRL_DP_HIGH|MCF_USB_OTG_OTG_CTRL_OTG_EN;
                                                         ^
../usb.c:47:31: error: 'U1IR' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_STAT  U1IR
                               ^
../usb.c:226:5: note: in expansion of macro 'MCF_USB_OTG_INT_STAT'
     MCF_USB_OTG_INT_STAT = 0xff;
     ^
../usb.c:48:30: error: 'U1IE' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_ENB  U1IE
                              ^
../usb.c:227:5: note: in expansion of macro 'MCF_USB_OTG_INT_ENB'
     MCF_USB_OTG_INT_ENB = MCF_USB_OTG_INT_ENB_USB_RST_EN;
     ^
../usb.c:49:41: error: '_U1IE_URSTIE_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_ENB_USB_RST_EN  _U1IE_URSTIE_MASK
                                         ^
../usb.c:227:27: note: in expansion of macro 'MCF_USB_OTG_INT_ENB_USB_RST_EN'
     MCF_USB_OTG_INT_ENB = MCF_USB_OTG_INT_ENB_USB_RST_EN;
                           ^
../usb.c: In function 'usb_device_default':
../usb.c:50:27: error: 'U1ADDR' undeclared (first use in this function)
 #define MCF_USB_OTG_ADDR  U1ADDR
                           ^
../usb.c:237:5: note: in expansion of macro 'MCF_USB_OTG_ADDR'
     MCF_USB_OTG_ADDR = (uint8)0;
     ^
../usb.c:42:26: error: 'U1CON' undeclared (first use in this function)
 #define MCF_USB_OTG_CTL  U1CON
                          ^
../usb.c:240:5: note: in expansion of macro 'MCF_USB_OTG_CTL'
     MCF_USB_OTG_CTL |= MCF_USB_OTG_CTL_ODD_RST;
     ^
../usb.c:51:34: error: '_U1CON_PPBRST_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_CTL_ODD_RST  _U1CON_PPBRST_MASK
                                  ^
../usb.c:240:24: note: in expansion of macro 'MCF_USB_OTG_CTL_ODD_RST'
     MCF_USB_OTG_CTL |= MCF_USB_OTG_CTL_ODD_RST;
                        ^
../usb.c:47:31: error: 'U1IR' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_STAT  U1IR
                               ^
../usb.c:255:5: note: in expansion of macro 'MCF_USB_OTG_INT_STAT'
     MCF_USB_OTG_INT_STAT = 0xff;
     ^
../usb.c:48:30: error: 'U1IE' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_ENB  U1IE
                              ^
../usb.c:256:5: note: in expansion of macro 'MCF_USB_OTG_INT_ENB'
     MCF_USB_OTG_INT_ENB |= MCF_USB_OTG_INT_ENB_SLEEP_EN|MCF_USB_OTG_INT_ENB_TOK_DNE_EN;
     ^
../usb.c:52:39: error: '_U1IE_IDLEIE_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_ENB_SLEEP_EN  _U1IE_IDLEIE_MASK
                                       ^
../usb.c:256:28: note: in expansion of macro 'MCF_USB_OTG_INT_ENB_SLEEP_EN'
     MCF_USB_OTG_INT_ENB |= MCF_USB_OTG_INT_ENB_SLEEP_EN|MCF_USB_OTG_INT_ENB_TOK_DNE_EN;
                            ^
../usb.c:53:41: error: '_U1IE_TRNIE_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_ENB_TOK_DNE_EN  _U1IE_TRNIE_MASK
                                         ^
../usb.c:256:57: note: in expansion of macro 'MCF_USB_OTG_INT_ENB_TOK_DNE_EN'
     MCF_USB_OTG_INT_ENB |= MCF_USB_OTG_INT_ENB_SLEEP_EN|MCF_USB_OTG_INT_ENB_TOK_DNE_EN;
                                                         ^
../usb.c: In function 'usb_device_enqueue':
../usb.c:54:36: error: '_U1EP0_EPHSHK_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_ENDPT_EP_HSHK  _U1EP0_EPHSHK_MASK
                                    ^
../usb.c:287:10: note: in expansion of macro 'MCF_USB_OTG_ENDPT_EP_HSHK'
     ep = MCF_USB_OTG_ENDPT_EP_HSHK|MCF_USB_OTG_ENDPT_EP_TX_EN|MCF_USB_OTG_ENDPT_EP_RX_EN;
          ^
../usb.c:55:37: error: '_U1EP0_EPTXEN_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_ENDPT_EP_TX_EN  _U1EP0_EPTXEN_MASK
                                     ^
../usb.c:287:36: note: in expansion of macro 'MCF_USB_OTG_ENDPT_EP_TX_EN'
     ep = MCF_USB_OTG_ENDPT_EP_HSHK|MCF_USB_OTG_ENDPT_EP_TX_EN|MCF_USB_OTG_ENDPT_EP_RX_EN;
                                    ^
../usb.c:56:37: error: '_U1EP0_EPRXEN_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_ENDPT_EP_RX_EN  _U1EP0_EPRXEN_MASK
                                     ^
../usb.c:287:63: note: in expansion of macro 'MCF_USB_OTG_ENDPT_EP_RX_EN'
     ep = MCF_USB_OTG_ENDPT_EP_HSHK|MCF_USB_OTG_ENDPT_EP_TX_EN|MCF_USB_OTG_ENDPT_EP_RX_EN;
                                                               ^
../usb.c:57:39: error: '_U1EP0_EPCONDIS_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_ENDPT_EP_CTL_DIS  _U1EP0_EPCONDIS_MASK
                                       ^
../usb.c:288:20: note: in expansion of macro 'MCF_USB_OTG_ENDPT_EP_CTL_DIS'
     ep |= endpoint?MCF_USB_OTG_ENDPT_EP_CTL_DIS:0;
                    ^
../usb.c:292:13: error: 'U1EP0' undeclared (first use in this function)
             U1EP0 = (uint8)(ep);
             ^
../usb.c:295:13: error: 'U1EP1' undeclared (first use in this function)
             U1EP1 = (uint8)(ep);
             ^
../usb.c:298:13: error: 'U1EP2' undeclared (first use in this function)
             U1EP2 = (uint8)(ep);
             ^
../usb.c:301:13: error: 'U1EP3' undeclared (first use in this function)
             U1EP3 = (uint8)(ep);
             ^
../usb.c: In function 'usb_isr':
../usb.c:47:31: error: 'U1IR' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_STAT  U1IR
                               ^
../usb.c:340:9: note: in expansion of macro 'MCF_USB_OTG_INT_STAT'
     if (MCF_USB_OTG_INT_STAT & MCF_USB_OTG_INT_STAT_TOK_DNE) {
         ^
../usb.c:58:39: error: '_U1IR_TRNIF_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_STAT_TOK_DNE  _U1IR_TRNIF_MASK
                                       ^
../usb.c:340:32: note: in expansion of macro 'MCF_USB_OTG_INT_STAT_TOK_DNE'
     if (MCF_USB_OTG_INT_STAT & MCF_USB_OTG_INT_STAT_TOK_DNE) {
                                ^
../usb.c:59:27: error: 'U1STAT' undeclared (first use in this function)
 #define MCF_USB_OTG_STAT  U1STAT
                           ^
../usb.c:356:16: note: in expansion of macro 'MCF_USB_OTG_STAT'
         stat = MCF_USB_OTG_STAT;
                ^
../usb.c:60:30: error: '_U1STAT_DIR_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_STAT_TX  _U1STAT_DIR_MASK
                              ^
../usb.c:357:25: note: in expansion of macro 'MCF_USB_OTG_STAT_TX'
         tx = !! (stat & MCF_USB_OTG_STAT_TX);
                         ^
../usb.c:61:31: error: '_U1STAT_PPBI_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_STAT_ODD  _U1STAT_PPBI_MASK
                               ^
../usb.c:358:26: note: in expansion of macro 'MCF_USB_OTG_STAT_ODD'
         odd = !! (stat & MCF_USB_OTG_STAT_ODD);
                          ^
../usb.c:42:26: error: 'U1CON' undeclared (first use in this function)
 #define MCF_USB_OTG_CTL  U1CON
                          ^
../usb.c:388:13: note: in expansion of macro 'MCF_USB_OTG_CTL'
             MCF_USB_OTG_CTL &= ~MCF_USB_OTG_CTL_TXSUSPEND_TOKENBUSY;
             ^
../usb.c:62:46: error: '_U1CON_TOKBUSY_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_CTL_TXSUSPEND_TOKENBUSY  _U1CON_TOKBUSY_MASK
                                              ^
../usb.c:388:33: note: in expansion of macro 'MCF_USB_OTG_CTL_TXSUSPEND_TOKENBUSY'
             MCF_USB_OTG_CTL &= ~MCF_USB_OTG_CTL_TXSUSPEND_TOKENBUSY;
                                 ^
../usb.c:50:27: error: 'U1ADDR' undeclared (first use in this function)
 #define MCF_USB_OTG_ADDR  U1ADDR
                           ^
../usb.c:563:21: note: in expansion of macro 'MCF_USB_OTG_ADDR'
                     MCF_USB_OTG_ADDR |= next_address;
                     ^
../usb.c:63:39: error: '_U1IR_URSTIF_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_STAT_USB_RST  _U1IR_URSTIF_MASK
                                       ^
../usb.c:587:32: note: in expansion of macro 'MCF_USB_OTG_INT_STAT_USB_RST'
     if (MCF_USB_OTG_INT_STAT & MCF_USB_OTG_INT_STAT_USB_RST) {
                                ^
../usb.c:64:37: error: '_U1IR_IDLEIF_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_STAT_SLEEP  _U1IR_IDLEIF_MASK
                                     ^
../usb.c:607:32: note: in expansion of macro 'MCF_USB_OTG_INT_STAT_SLEEP'
     if (MCF_USB_OTG_INT_STAT & MCF_USB_OTG_INT_STAT_SLEEP) {
                                ^
../usb.c:48:30: error: 'U1IE' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_ENB  U1IE
                              ^
../usb.c:612:9: note: in expansion of macro 'MCF_USB_OTG_INT_ENB'
         MCF_USB_OTG_INT_ENB &= ~MCF_USB_OTG_INT_ENB_SLEEP_EN;
         ^
../usb.c:52:39: error: '_U1IE_IDLEIE_MASK' undeclared (first use in this function)
 #define MCF_USB_OTG_INT_ENB_SLEEP_EN  _U1IE_IDLEIE_MASK
                                       ^
../usb.c:612:33: note: in expansion of macro 'MCF_USB_OTG_INT_ENB_SLEEP_EN'
         MCF_USB_OTG_INT_ENB &= ~MCF_USB_OTG_INT_ENB_SLEEP_EN;
                                 ^
../usb.c: In function 'usb_uninitialize':
../usb.c:42:26: error: 'U1CON' undeclared (first use in this function)
 #define MCF_USB_OTG_CTL  U1CON
                          ^
../usb.c:690:5: note: in expansion of macro 'MCF_USB_OTG_CTL'
     MCF_USB_OTG_CTL = 0;
     ^
../usb.c:44:31: error: 'U1OTGCON' undeclared (first use in this function)
 #define MCF_USB_OTG_OTG_CTRL  U1OTGCON
                               ^
../usb.c:691:5: note: in expansion of macro 'MCF_USB_OTG_OTG_CTRL'
     MCF_USB_OTG_OTG_CTRL = 0;
     ^
../usb.c:694:5: error: 'U1PWRCbits' undeclared (first use in this function)
     U1PWRCbits.USBPWR = 0;
     ^
../usb.c: In function 'usb_initialize':
../usb.c:718:5: error: 'U1PWRCbits' undeclared (first use in this function)
     U1PWRCbits.USBPWR = 1;
     ^
../usb.c:65:31: error: 'U1SOF' undeclared (first use in this function)
 #define MCF_USB_OTG_SOF_THLD  U1SOF
                               ^
../usb.c:727:5: note: in expansion of macro 'MCF_USB_OTG_SOF_THLD'
     MCF_USB_OTG_SOF_THLD = 74;
     ^
../usb.c:66:34: error: 'U1BDTP1' undeclared (first use in this function)
 #define MCF_USB_OTG_BDT_PAGE_01  U1BDTP1
                                  ^
../usb.c:731:5: note: in expansion of macro 'MCF_USB_OTG_BDT_PAGE_01'
     MCF_USB_OTG_BDT_PAGE_01 = (uint8)(KVA_2_PA((unsigned int)bdts) >> 8);
     ^
../usb.c:67:34: error: 'U1BDTP2' undeclared (first use in this function)
 #define MCF_USB_OTG_BDT_PAGE_02  U1BDTP2
                                  ^
../usb.c:732:5: note: in expansion of macro 'MCF_USB_OTG_BDT_PAGE_02'
     MCF_USB_OTG_BDT_PAGE_02 = (uint8)(KVA_2_PA((unsigned int)bdts) >> 16);
     ^
../usb.c:68:34: error: 'U1BDTP3' undeclared (first use in this function)
 #define MCF_USB_OTG_BDT_PAGE_03  U1BDTP3
                                  ^
../usb.c:733:5: note: in expansion of macro 'MCF_USB_OTG_BDT_PAGE_03'
     MCF_USB_OTG_BDT_PAGE_03 = (uint8)(KVA_2_PA((unsigned int)bdts) >> 24);
     ^
make[2]: *** [build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/usb.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -g -x c -c -mprocessor=32MZ2048EFM144 -D_BOARD_MICROCHIP_ETH_START_KIT_USB_ -I.. -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/cdcacm.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/cdcacm.o ../cdcacm.c -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder 
"/Applications/microchip/xc32/v2.05/bin/xc32-gcc" -g -x c -c -mprocessor=32MZ2048EFM144 -D_BOARD_MICROCHIP_ETH_START_KIT_USB_ -I.. -MMD -MF build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o.d -o build/MICROCHIP_MZ_STARTER_KIT_USB/production/_ext/1472/main.o ../main.c -DXPRJ_MICROCHIP_MZ_STARTER_KIT_USB=MICROCHIP_MZ_STARTER_KIT_USB -no-legacy-libc -ftoplevel-reorder 
make[2]: Leaving directory '/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/chipKIT-Bootloaders.X'
nbproject/Makefile-MICROCHIP_MZ_STARTER_KIT_USB.mk:103: recipe for target '.build-conf' failed
make[1]: Leaving directory '/Users/bittond/GoogleDrive/src/PIC32-avrdude-bootloader/bootloaders/chipKIT-Bootloaders.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUILD FAILED (exit value 2, total time: 682ms)

I need to do some addt'l poking around.

@davidbitton
Copy link
Author

I tried replicating this:

library_directories_and_project_properties_-_chipkit-bootloaders

with this:

library_directories_and_project_properties_-_chipkit-bootloaders

and still no-go. The search goes on.

@EmbeddedMan
Copy link
Member

Ahhh. @majenkotech may be able to help us here.

Matt, is this because the bootloader (as it stands now) doesn't support MZ USB? (I can't remember what the state of things are.)

@davidbitton
Copy link
Author

For example, where is U1CON defined and how are you including it for the Fubarino SD USB?

@davidbitton
Copy link
Author

@EmbeddedMan I think you're onto something. I'm guessing based on this, that U1CON doesn't exist for a pic32mz...

searching_ microchip and_searching pic32-avrdude-bootloader and_mplab_harmony___microchip_technology_inc____microchip_technology_inc

@majenkotech
Copy link
Member

You cannot use the PIC32 avrdude bootloader with the MZ chips for anything other than simple UART access. No amount of bending the code will fix it - the plain and simple fact is there is no USB stack there for the MZ chips.

Which is why I wrote my own AN1388 compatible bootloader for the MZ chips using the new USB stack in the forthcoming version of chipKIT.

@davidbitton
Copy link
Author

davidbitton commented Feb 8, 2018

@majenkotech how do I go about using this w. my PIC32MZ2048EFM144 starter board? Also, which board target shall I use in the Arduino IDE as the starter kit board is not listed amongst the chipKit-core boards?

@majenkotech
Copy link
Member

Step one is to get the Arduino IDE working with the github version of the core. Then load the sketch and make sure the config bits are right for your board, and tweak anything else that needs tweaking.

You'll also need to make a custom board in the boards.txt file that uses the linker scripts in the MZBoot repo.

Then compile it and (find and) burn the .HEX file using your chosen programmer (you can't do that bit from the IDE - use MPLAB-X IPE or something for that).

Then cross your fingers and hope it works. You'll need the latest pic32prog as well (https://github.com/majenkotech/pic32prog-autotools/releases/tag/2.1.37) as it fixes some nasty bugs in the AN1388 protocol.

If it works you will then need to make another new board in boards.txt to use the "hid" programming tool and set the VID/PID for programming. I forget what the values to set are off hand, since I never use the Arduino IDE :P

@davidbitton
Copy link
Author

davidbitton commented Feb 9, 2018

Should that custom board be a copy of an existing chipKit board? Shall I just overwrite the pic32prog in the Arduino folder with your pic32prog? do you use MPIDE?

@davidbitton
Copy link
Author

@majenkotech is OpenScope yours? Is it using the AN1388 bootloader?

@majenkotech
Copy link
Member

majenkotech commented Feb 9, 2018 via email

@majenkotech
Copy link
Member

Should that custom board be a copy of an existing chipKit board? Shall I just overwrite the pic32prog in the Arduino folder with your pic32prog? do you use MPIDE?

It should be copy of a board that provides the right pin configuration for your target board. If one doesn't exist you may get away with copying something that is close. Ideally, though you'd craft proper Board_Defs.h and Board_Data.c files for your board.

@davidbitton
Copy link
Author

I'm always looking for a challenge but I think a fair amount of this is above my pay grade. In the end, I just want an 36mm square MZ board with as many UARTs, SPI, I2C, and CAN as possible; little to no I/O. Well, onward and upward. Thanks!

@davidbitton
Copy link
Author

@majenkotech I just read something you wrote in the chipKit forum in 2014. Perhaps I shouldn't kill myself over getting "Arduino" working and just write some code. How's Harmony as a platform?

@majenkotech
Copy link
Member

As an idea Harmony is great. Its implementation, though, is a complete nightmare. That is, from my perspective. The code is so massively obfuscated and macrofied, that it's impossible to work out what is going on. I have never liked Microchip's programming style, and Harmony has it in spades. It's the kind of system where, if you know how it works, is possible to work with. However if you don't, you're pretty much screwed.

We tried integrating Harmony with chipKIT for the USB stack some time ago. It only just worked, and required someone from within the Harmony team to actually get us that far. By just worked, it was buggy as hell, with Linux complaining about being unable to get report descriptors and causing USB stack lockups and things. So after maybe 2 years of trying we gave up, and while on holiday for a week in wettest, windiest, West Wales I wrote an entire USB stack entirely from scratch.

The Arduino API (and especially the chipKIT variant of it) has come on a long way since I wrote that post. The facilities we now have, with the USB stack, DisplayCore, DFATFS, the I2S libraries I am currently working on, etc, in my opinion are both far easier and more powerful than Microchip's Harmony offering. The only caveat, though, is that you need a board definition for your board to be able to work with chipKIT, and that (especially for an MZ chip) can be a bit of a pain to create.

As far as the bootloader goes you can probably get away with using the Wi-FIRE as the basis (actually the No-FIRE would be better that Brian created, since it's not got the hacky crud that Digilent forced on us by switching chips suddenly and not wanting a new board definition) for your configuration. Just copy the section in boards.txt and give it a new name. Change the linker scripts to the ones in the repo, and it should just work.

The biggest problem will come when you want to actually use the board itself once you have the bootloader working. It's then that you really need a proper set of board definition files in order to map the peripherals and name the pins properly.

@davidbitton
Copy link
Author

OK. I will continue to plod along. Perhaps microchip can provide the definitions as it is there board I'm working with.

@majenkotech
Copy link
Member

majenkotech commented Feb 9, 2018

Nah. They'd just pass it on to Sharon, and she'd pass it on to me :P

I might have an MZEF Curiosity board here somewhere I think. Not sure how it compares to that one though. It does look somewhat like the experimental DA starter kit I have that I have been meaning to get to grips with though, but that's a BGA chip, so I'll bet the pinout's completely different.

@davidbitton
Copy link
Author

I followed your suggestion and used the PONTECH NoFire board type and received the following:

Programmer for Microchip PIC32 microcontrollers, Version 2.1.24
    Copyright: (C) 2011-2015 Serge Vakulenko
      Adapter: STK500v2 Bootloader
 Program area: 1d000000-1d1fffff
    Processor: Bootloader
 Flash memory: 2048 kbytes
  Boot memory: 80 kbytes
         Data: 17496 bytes
        Erase: done
Program flash: ..................������������������################### done
 Verify flash: ..................������������������#
error at address 1D000000: file=3C1A9D00, mem=FFFFFFFF
error at address 1D000000: file=3C1A9D00, mem=FFFFFFFF

I built and installed the bootloader for this board from within MPLAB X.

@majenkotech
Copy link
Member

I can see two things wrong there:

  1. You're not using the linker scripts from the MZ bootloader repo.
  2. You seem to be programming it through a bootloader that's already on there - so what exactly are you trying to achieve here?

@davidbitton
Copy link
Author

davidbitton commented Feb 9, 2018

yes, i'm NOT using your bootloader largely because I couldn't figure out the necessary steps to compile it. I want to see if I can get the UART method working first before I move on to something more experimental. Does that make sense?

@majenkotech
Copy link
Member

Ah right, I see. I thought you'd compiled the MZ bootloader and were trying to install it.

@davidbitton
Copy link
Author

@majenkotech didn't you say there was a new chipKit coming down the pike?

@majenkotech
Copy link
Member

Brian is working on that right now.

@EmbeddedMan
Copy link
Member

EmbeddedMan commented Feb 9, 2018 via email

@davidbitton
Copy link
Author

@EmbeddedMan should I hold off on doing anything further w. getting the starter board working until you release the new code?

@EmbeddedMan
Copy link
Member

EmbeddedMan commented Feb 9, 2018 via email

@davidbitton
Copy link
Author

@EmbeddedMan ok, duly noted. will there be updated bootloader code too?

@EmbeddedMan
Copy link
Member

EmbeddedMan commented Feb 9, 2018 via email

@davidbitton
Copy link
Author

davidbitton commented Feb 9, 2018

sigh

@davidbitton
Copy link
Author

@majenkotech I took your suggestion and created this boards.txt definition

############################################################
foo.name=MZBoot foo
foo.group=chipKit

# new items
foo.platform=pic32
foo.build.board=_BOARD_FOO_
foo.ldscript=MZ-application-32MZ2048EFG-bootseg.ld
# end of new items

foo.upload.protocol=stk500v2
foo.upload.maximum_size=2080768
foo.upload.maximum_data_size=524288
foo.upload.speed=115200
foo.upload.tool=pic32prog

foo.build.mcu=32MZ2048EFM144
foo.build.f_cpu=200000000UL
foo.build.core=pic32
foo.ldcommon=chipKIT-application-COMMON-MZ-bootseg.ld
foo.build.variant=MZBoot_foo
foo.build.ldscript.path={build.variant.path}

############################################################

and my build output is:

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/bittondb/Library/Arduino15/packages -hardware /Users/bittondb/Documents/Arduino/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/bittondb/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/bittondb/Documents/Arduino/libraries -fqbn=chipKIT:pic32:foo -ide-version=10612 -build-path /var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_720441 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.drivers-windows.path=/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/drivers-windows/v2 -prefs=runtime.tools.pic32-tools.path=/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/pic32-tools/1.43-pic32gcc -prefs=runtime.tools.pic32prog.path=/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/pic32prog/v2.1.24 -verbose /Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/bittondb/Library/Arduino15/packages -hardware /Users/bittondb/Documents/Arduino/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/bittondb/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/bittondb/Documents/Arduino/libraries -fqbn=chipKIT:pic32:foo -ide-version=10612 -build-path /var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_720441 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.drivers-windows.path=/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/drivers-windows/v2 -prefs=runtime.tools.pic32-tools.path=/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/pic32-tools/1.43-pic32gcc -prefs=runtime.tools.pic32prog.path=/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/pic32prog/v2.1.24 -verbose /Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino
Using board 'foo' from platform in folder: /Users/bittondb/Library/Arduino15/packages/chipKIT/hardware/pic32/1.4.3
Using core 'pic32' from platform in folder: /Users/bittondb/Library/Arduino15/packages/chipKIT/hardware/pic32/1.4.3
Warning: Board arduino:avr:lilypado doesn't define a 'build.board' preference. Auto-set to: AVR_LILYPADO
Detecting libraries used...
"/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/pic32-tools/1.43-pic32gcc/bin/pic32-g++" -c -g -O2 -w  -DARDUINO_ARCH_PIC32 -mno-smart-io -ffunction-sections -fdata-sections  -mdebugger -Wcast-align -fno-short-double -ftoplevel-reorder -fno-exceptions -w -x c++ -E -CC -mprocessor=32MZ2048EFM144 -DF_CPU=200000000UL -DARDUINO=10612 -D_BOARD_FOO_ -DARDUINO_ARCH_PIC32 -DMPIDEVER=16777998 -DMPIDE=150 -DIDE=Arduino   -I/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_720441/sketch "-I/Users/bittondb/Library/Arduino15/packages/chipKIT/hardware/pic32/1.4.3/cores/pic32" "-I/Users/bittondb/Library/Arduino15/packages/chipKIT/hardware/pic32/1.4.3/variants/MZBoot" "/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_720441/sketch/MZBoot.ino.cpp" -o "/dev/null"
"/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/pic32-tools/1.43-pic32gcc/bin/pic32-g++" -c -g -O2 -w  -DARDUINO_ARCH_PIC32 -mno-smart-io -ffunction-sections -fdata-sections  -mdebugger -Wcast-align -fno-short-double -ftoplevel-reorder -fno-exceptions -w -x c++ -E -CC -mprocessor=32MZ2048EFM144 -DF_CPU=200000000UL -DARDUINO=10612 -D_BOARD_FOO_ -DARDUINO_ARCH_PIC32 -DMPIDEVER=16777998 -DMPIDE=150 -DIDE=Arduino   -I/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_720441/sketch "-I/Users/bittondb/Library/Arduino15/packages/chipKIT/hardware/pic32/1.4.3/cores/pic32" "-I/Users/bittondb/Library/Arduino15/packages/chipKIT/hardware/pic32/1.4.3/variants/MZBoot" "/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_720441/sketch/MZBoot.ino.cpp" -o "/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_720441/preproc/ctags_target_for_gcc_minus_e.cpp"
/Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino:51:19: fatal error: Flash.h: No such file or directory
 #include <Flash.h>
                   ^
compilation terminated.
exit status 255
Error compiling for board MZBoot foo.f

I must be missing a step.

@majenkotech
Copy link
Member

majenkotech commented Feb 10, 2018 via email

@majenkotech
Copy link
Member

@davidbitton
Copy link
Author

@majenkotech making progress. I had the add your USB library as well along with an #include, however HID.onOutputReport(outputReport); throws an error.

MZBoot:274: error: 'class HID_Raw' has no member named 'onOutputReport'

I searched around GitHub and Google without luck. Thanks.

@majenkotech
Copy link
Member

Did you read the big bold message at the top of the README file for the USB library?

IMPORTANT

THIS LIBRARY IS DEPRECATED. IT IS NOW OUT OF DATE. IT HAS BEEN INTEGRATED WITH THE CHIPKIT CORE ITSELF TO BE RELEASED IN VERSION 2.0.0. BUGFIXES AND IMPROVEMENTS WILL NOT BE ADDED TO THIS LIBRARY.

Also read what I wrote up there ^^^^^ - you need the GITHUB version of chipKIT core (which is just on the verge of release).

@davidbitton
Copy link
Author

ok, using the github core, I'm here now:

"/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/pic32-tools/1.43-pic32gcc/bin/pic32-g++" -w -Os -Wl,--save-gld=/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch.ld,-Map=/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch.map,--gc-sections -mdebugger -mno-peripheral-libs -nostartfiles -mprocessor=32MZ2048EFM144  -o "/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/MZBoot.ino.elf" "/Users/bittondb/Documents/Arduino/hardware/chipkit-core/pic32/cores/pic32/cpp-startup.S" "/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch/MZBoot.ino.cpp.o" "/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/libraries/Flash/Flash.cpp.o" "/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/core/Board_Data.c.o" "/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/core/core.a" -L/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648 -lm  -T "/Users/bittondb/Documents/Arduino/hardware/chipkit-core/pic32/variants/MZBoot/MZ-application-32MZ2048EFG-bootseg.ld" -T "/Users/bittondb/Documents/Arduino/hardware/chipkit-core/pic32/cores/pic32/chipKIT-application-COMMON-MZ-bootseg.ld"
/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch/MZBoot.ino.cpp.o: In function `sendPacket(unsigned char*, unsigned long)':
/Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino:155: undefined reference to `HID_Raw::sendReport(unsigned char*, unsigned char)'
/Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino:155: undefined reference to `HID_Raw::sendReport(unsigned char*, unsigned char)'
/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch/MZBoot.ino.cpp.o: In function `executeApp()':
/Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino:191: undefined reference to `USBManager::end()'
/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch/MZBoot.ino.cpp.o: In function `USBManager::addDevice(USBDevice&)':
/Users/bittondb/Documents/Arduino/hardware/chipkit-core/pic32/cores/pic32/USB.h:281: undefined reference to `USBManager::addDevice(USBDevice*)'
/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch/MZBoot.ino.cpp.o: In function `setup':
/Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino:275: undefined reference to `USBManager::begin()'
/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch/MZBoot.ino.cpp.o: In function `USBHS':
/Users/bittondb/Documents/Arduino/hardware/chipkit-core/pic32/cores/pic32/USB.h:205: undefined reference to `vtable for USBHS'
/Users/bittondb/Documents/Arduino/hardware/chipkit-core/pic32/cores/pic32/USB.h:205: undefined reference to `vtable for USBHS'
/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch/MZBoot.ino.cpp.o: In function `__static_initialization_and_destruction_0':
/Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino:55: undefined reference to `USBManager::USBManager(USBDriver&, unsigned short, unsigned short, char const*, char const*, char const*)'
/Users/bittondb/GoogleDrive/src/MZBoot/MZBoot.ino:55: undefined reference to `USBHS::_this'
/var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_772648/sketch/MZBoot.ino.cpp.o: In function `HID_Raw':
/Users/bittondb/Documents/Arduino/hardware/chipkit-core/pic32/cores/pic32/USB.h:774: undefined reference to `vtable for HID_Raw'
/Users/bittondb/Documents/Arduino/hardware/chipkit-core/pic32/cores/pic32/USB.h:774: undefined reference to `vtable for HID_Raw'
collect2: error: ld returned 255 exit status
Using library Flash in folder: /Users/bittondb/Documents/Arduino/libraries/Flash (legacy)
exit status 255
Error compiling for board MZBoot foo.

I also removed your old USB lib so Arduino won't pick it up.

@EmbeddedMan
Copy link
Member

EmbeddedMan commented Feb 12, 2018 via email

@davidbitton
Copy link
Author

@EmbeddedMan ok, @majenkotech 's code compiled this time. I just loaded the generated .hex file onto the board. Now I have to try and get it to work.

@davidbitton
Copy link
Author

not so much luck. it looks like Arduino wants to program via UART. Not sure how to properly craft the bits necessary for the Arduino IDE. I copied the NoFire settings, but, well, yeah, didn't work. I'm about ready to walk away from using this board.

@majenkotech
Copy link
Member

majenkotech commented Feb 14, 2018

You need to create your target board specification with the right settings to use the right programming parameteters.

You need to set:

usb.protocol=an1388
usb.vid=04d8
usb.pid=0f5f
upload.tool=pic32prog-hid

(or that's if I recall correctly).

@davidbitton
Copy link
Author

Ok, we have some progress. This is where I'm at:

Sketch uses 5,156 bytes (0%) of program storage space. Maximum is 2,080,768 bytes.
Global variables use 3,236 bytes (0%) of dynamic memory, leaving 521,052 bytes for local variables. Maximum is 524,288 bytes.
/Users/bittondb/Library/Arduino15/packages/chipKIT/tools/pic32prog/v2.1.37/pic32prog -d an1388:04d8:8107 -R 20 /var/folders/nk/n29krwvj22s9xfk72mk0tt7h0000gn/T/arduino_build_593711/sketch_feb14a.ino.hex 
    Copyright: (C) 2011-2015 Serge Vakulenko
                   2016-2017 Majenko Technologies
Programmer for Microchip PIC32 microcontrollers, Version 2.1.37

*** Enter programming mode now. ***

From my boards.txt:

microchip_starter.name=microchip starter
microchip_starter.group=microchip

microchip_starter.usb.enabled=true
microchip_starter.usb.default=a_cdcacm

# new items
microchip_starter.platform=pic32
microchip_starter.build.board=_BOARD_MICROCHIP_STARTER_
microchip_starter.ldscript=MZ-application-32MZ2048ECX.ld
# end of new items

microchip_starter.upload.protocol=an1388
microchip_starter.upload.maximum_size=2080768
microchip_starter.upload.maximum_data_size=524288
microchip_starter.upload.speed=115200
microchip_starter.upload.tool=pic32prog-hid

microchip_starter.usb.vid=04d8
microchip_starter.usb.pid=8107
microchip_starter.usb.protocol=an1388
microchip_starter.usb.verbose=true

microchip_starter.build.mcu=32MZ2048EFM144
microchip_starter.build.f_cpu=200000000UL
microchip_starter.build.core=pic32
microchip_starter.ldcommon=chipKIT-application-COMMON-MZ.ld
microchip_starter.build.variant=microchip_starter
microchip_starter.build.ldscript.path={build.variant.path}

I'm guessing I'm missing a step.

@davidbitton
Copy link
Author

@majenkotech also, I went back to MZBoot and changed the pid to match the microchip board.

Product ID:	0x8107
Vendor ID:	0x04d8  (Microchip Technology Inc.)
USBManager USB(usbDriver, 0x04d8, 0x8107, "chipKIT", "HID Bootloader");

You can see I have the same pid/vid combo in the boards.txt file.

@majenkotech
Copy link
Member

Is the board being detected by your operating system?

@davidbitton
Copy link
Author

Yes, that's how I was able to grab the pid/vid. Further, if I unplug the board while pic32prog is waiting, pic32prog kicks out an error about losing contact. Also, if I run pic32prog from the command line using the line generated by the IDE and change a digit in the pid/vid, I receive an error about not being able to find the board; bad pid/vid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants