Compiling CVpal firmware

I’ve got two CVPals and I’d like to be able to run them both off my laptop at once. In order to do that I need to give them unique USB device names by changing this line in usb_config.h:

#define USB_CFG_DEVICE_NAME ‘C’, ‘V’, ‘p’, ‘a’, ‘l’

… so that one is called, say, CVgal, and then I need to recompile and re upload the firmware. I couldn’t find any specific instructions on doing this for the CVPal so I’d like to document my progress here for others and maybe get some help along the way. I’m on a Mac, BTW.

First, from the Terminal, I run ‘git clone https://github.com/pichenettes/cvpal’ to make a local copy of the code.

From within the cvpal directory I run: ‘git pull origin master’ and then ‘git submodule init && git submodule update’ to get the required submodules.

On Olivier’s advice I’ve installed an older version of CrossPack (CrossPack-AVR-20100115.dmg) and avrdude. Now I go for a compile:

‘make -f cvpal/makefile’

This creates a ‘cvpal/build’ directory which contains a cvpal.hex - could this be success?! I will have to wait for my ISP programmer to arrive so I can try uploading it. I’ll post an update here.

Thanks, Olivier, for your help & advice.

1 Like

Problem with: git submodule init && git submodule update

=> First run “git pull origin master”, then try this command again.

The public repo contained a reference to a private repo. I’ve just fixed this.

“Having installed CrossPack and avrdude”

Try CrossPack-AVR-20100115.dmg instead of the more recent versions.

OK, I’ve finally finished moving house and I have some time to get back to this project! I got my usbasp (ISP) in the mail and I’ve connected the VCC, GND, MOSI, MISO, RST, and SCK.

From the CVpal DIY Resources page it looks like there are two commands to run:

$ avrdude -V -p t84 -c usbasp -P usb -B 10 -e -u -U efuse:w:0xff:m -U hfuse:w:0xd6:m -U lfuse:w:0xde:m -U lock:w:0x2f:m

avrdude: set SCK frequency to 93750 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e930c
avrdude: erasing chip
avrdude: set SCK frequency to 93750 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "0xff"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: reading input file "0xd6"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: reading input file "0xde"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: reading input file "0x2f"
avrdude: writing lock (1 bytes):

Writing | | 0% 0.00s *****failed;
Writing | ################################################## | 100% 0.07s

avrdude: 1 bytes of lock written

avrdude done. Thank you.

OK, that looks like it worked, I guess. The last lock tried to write once and failed but then tried again and suceeded.

The second command is less successful:

$ avrdude -V -p t84 -c usbasp -P usb -B 1 -U flash:w:cvpal.hex:i -U lock:w:0x2f:m

avrdude: set SCK frequency to 750000 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm enable: target doesn’t answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.

Any idea what’s wrong here?

Thanks!

Hmm. It seems it talks to the MCU since the first command works. You could try “-B 10” in the second command too (to see if it works with the slower transfer speed).

Also, is the MCU sitting in the CVpal when you try to program it? The fuse settings disable the internal clock oscillator so I think it needs the external crystal for programming to work.

Thanks for the reply. In fact the MCU was just mounted on my breadboard and was I just getting 'round to wondering if it needed to be mounted in the CVPal. I’ve just soldered a 3x2 header to the CVPal and then hooked up the pins from my programmer (usb asp), ran the two commands and they appear to have worked: indeed when I plug the module in it shows up as a midi device! Unfortunately, it still shows up as CVpal, not CVgal… argh! I need to go take another look for that string in the source but this has been enough excitement for one night…

Woo hoo - finally got it working! I also needed to edit this line: USB_CFG_SERIAL_NUMBER to reflect my new name. Thanks for the help, guys. Hope this thread is helpful to others.

1 Like