Giter Site home page Giter Site logo

urjaman / frser-duino Goto Github PK

View Code? Open in Web Editor NEW
67.0 12.0 26.0 102 KB

Reimplementation of serprog-duino based on the original flashrom serprog interfacing code (now libfrser).

License: GNU General Public License v2.0

C 77.58% Makefile 22.42%

frser-duino's Introduction

frser-duino

Alternative code to serprog-duino.
We're in process of melding all the good bits of serprog-duino into frser-duino and deprecating serprog-duino.

Available targets (same as with serprog-duino):

  • ftdi, flash-ftdi:
    For the Arduinos with an FTDI
    compatible flashrom arguments: flashrom -p serprog:dev=/dev/ttyUSB0:2000000
    Other boards using an hardware USB<->Serial converter might work too.

  • u2, flash-u2:
    For the Arduino with a 8u2 or a 16u2
    compatible flashrom arguments: flashrom -p serprog:dev=/dev/ttyACM0:115200

Traditional targets:
make - builds
make program - "flashes"

These are by default effectively synonyms for u2 and flash-u2, except that "make" doesnt clean out the previous build if it sees no changes. You can change what the traditional targets do by either changing the defines at the beginning of the makefile, or using environment variables - for example:
BLBAUD=115200 SERIAL_DEV=/dev/ttyUSB1 make program

Note: the repository has a submodule, clone with --recursive.

About the various (broken) usb-serial converters

  • Arduino Uno with ATMega 8U2/16U2: their default firmware is quite broken,
    but the default settings works around it at 115200 (slowly).

    If you're willing to test, I have an alternative firmware for it:
    https://github.com/urjaman/fast-usbserial
    with that firmware you should be able to use it as if it was an FTDI, meaning with make ftdi and at 2Mbaud. This means that for this case it would be valid to say make ftdi; make flash-u2. The flash targets dont check what kind of binary they're flashing.
    (Note: My benchmarks say it is still slower than the FTDI.)

  • A "VISduino" named Uno R3 clone with with a CH340G:
    It is a cheap usb-serial converter chip, and if it in general works on your computer (google had reports of it not working with all usb chipsets) you can treat it like an FTDI with a maximum baudrate of 115200. Claims 2Mbaud but apparently doesnt have big enough buffers for operation at that speed.
    Commands would be (if you dont touch the defaults in Makefile):
    DFLAGS=-DFTDI make clean all and SERIAL_DEV=/dev/ttyUSB0 make program

Using an Arduino and an external usb-serial converter

If you have an Arduino without a FTDI chip, but you are lucky enough to have an extra usb-serial converter laying around, you can use it to speed up the flashing. Just connect the usb-serial converter with the RX(Pin 0), TX(Pin 1) and GND pins on your Arduino and use the instructions for the ftdi target from above.

frser-duino's People

Contributors

neuschaefer avatar sudden6 avatar tomvanveen avatar urjaman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frser-duino's Issues

No information about neccesary libraries in README.

While trying to compile and flash to Arduino Nano clone i have some problems with finding proper libriaries.
I think it will be nice to write hint for future users what libriaries are neccesary and how to install them.
For example what i was neccesary to do on Ubuntu 18.04:

sudo apt install gcc-avr avr-libc avrdude

For less technical people is not so obvious :)

Mega2560 requires upload.protocol stk500v2

(Mega 2560 R3)
avrdude -c arduino -p m2560 -P /dev/ttyACM0 -b 115200 -U flash:w:frser-duino.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

should be avrdude -c stk500v2 -p m2560 -P /dev/ttyACM0 -b 115200 -U flash:w:frser-duino.hex

Error: Programmer initialization failed

Hi, I am trying to compile the code but at the end it gives error massage.
This is the way I do it :

farid@Farid-PC:~$ sudo apt-get install git make gcc-avr avr-libc flashrom avrdude
[sudo] password for farid:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
make is already the newest version (4.3-4.1build1).
avr-libc is already the newest version (1:2.0.0+Atmel3.6.2-3).
avrdude is already the newest version (6.3-20171130+svn1429-2).
flashrom is already the newest version (1.2-5build1).
gcc-avr is already the newest version (1:5.4.0+Atmel3.6.2-3).
git is already the newest version (1:2.34.1-1ubuntu1.8).
0 upgraded, 0 newly installed, 0 to remove and 129 not upgraded.

==========================================

farid@Farid-PC:~$ git clone --recursive https://github.com/urjaman/frser-duino.git
Cloning into 'frser-duino'...
remote: Enumerating objects: 363, done.
remote: Total 363 (delta 0), reused 0 (delta 0), pack-reused 363
Receiving objects: 100% (363/363), 101.32 KiB | 435.00 KiB/s, done.
Resolving deltas: 100% (242/242), done.
Submodule 'libfrser' (https://github.com/urjaman/libfrser.git) registered for path 'libfrser'
Cloning into '/home/farid/frser-duino/libfrser'...
remote: Enumerating objects: 408, done.
remote: Total 408 (delta 0), reused 0 (delta 0), pack-reused 408
Receiving objects: 100% (408/408), 123.07 KiB | 168.00 KiB/s, done.
Resolving deltas: 100% (271/271), done.
Submodule path 'libfrser': checked out 'a628f1961a6b83a3f135aa47fbf7078da89018cd'

==========================================

farid@Farid-PC:~$ cd frser-duino

==========================================

farid@Farid-PC:~/frser-duino$ make ftdi
make clean
make[1]: Entering directory '/home/farid/frser-duino'
rm -f frser-duino.bin
rm -f frser-duino.out
rm -f frser-duino.hex
rm -f frser-duino.s
rm -f *.o
make[1]: Leaving directory '/home/farid/frser-duino'
DFLAGS=-DFTDI FRBAUD=2000000 make all
make[1]: Entering directory '/home/farid/frser-duino'
avr-gcc -mmcu=atmega328p -DBAUD=2000000 -Os -fno-inline-small-functions -fno-tree-switch-conversion -frename-registers -g -Wall -W -pipe -flto -fwhole-program -std=gnu99 -DFTDI -Ilibfrser -std=gnu99 -I. -o frser-duino.out main.c uart.c spihw.c libfrser/frser.c libfrser/udelay.c libfrser/spilib.c libfrser/spihw_avrspi.c
avr-size frser-duino.out
text data bss dec hex filename
1416 0 1036 2452 994 frser-duino.out
make[1]: Leaving directory '/home/farid/frser-duino'

==========================================

farid@Farid-PC:~/frser-duino$ avr-objcopy -j .text -j .data -O ihex frser-duino.out frser-duino.hex

==========================================

farid@Farid-PC:~/frser-duino$ avrdude -c usbasp -p m328p -u -U flash:w:frser-duino.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "frser-duino.hex"
avrdude: input file frser-duino.hex auto detected as Intel Hex
avrdude: writing flash (1416 bytes):

Writing | ################################################## | 100% 11.09s

avrdude: 1416 bytes of flash written
avrdude: verifying flash memory against frser-duino.hex:
avrdude: load data flash data from input file frser-duino.hex:
avrdude: input file frser-duino.hex auto detected as Intel Hex
avrdude: input file frser-duino.hex contains 1416 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 6.87s

avrdude: verifying ...
avrdude: 1416 bytes of flash verified

avrdude done. Thank you.

==========================================

farid@Farid-PC:~/frser-duino$ flashrom -p serprog:dev=/dev/ttyUSB0:115200
flashrom v1.2 on Linux 5.19.0-32-generic (x86_64)
flashrom is free software, get the source code at https://flashrom.org

Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Error: cannot synchronize protocol - check communications and reset device?
Error: Programmer initialization failed.

==========================================

and by the way I am sure about the wiring and hardware because when I use the hex file from this site it seems to work, but when I try to compile the hex it doesn't work.
any idea why my own compiled hex file doesn't work?

farid@Farid-PC:~$ flashrom -p serprog:dev=/dev/ttyUSB0:115200
flashrom v1.2 on Linux 5.19.0-32-generic (x86_64)
flashrom is free software, get the source code at https://flashrom.org

Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
serprog: Programmer name is "frser-duino"
serprog: requested mapping AT45CS1282 is incompatible: 0x1080000 bytes at 0x00000000fef80000.
serprog: requested mapping GD25Q256D is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping IS25LP256 is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping IS25WP256 is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping MX25L25635F/MX25L25645G is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping MX25U25635F is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping MX25U51245G is incompatible: 0x4000000 bytes at 0x00000000fc000000.
serprog: requested mapping MX66L51235F/MX25L51245G is incompatible: 0x4000000 bytes at 0x00000000fc000000.
serprog: requested mapping N25Q00A..1G is incompatible: 0x8000000 bytes at 0x00000000f8000000.
serprog: requested mapping N25Q00A..3G is incompatible: 0x8000000 bytes at 0x00000000f8000000.
serprog: requested mapping N25Q256..1E is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping N25Q256..3E is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping N25Q512..1G is incompatible: 0x4000000 bytes at 0x00000000fc000000.
serprog: requested mapping N25Q512..3G is incompatible: 0x4000000 bytes at 0x00000000fc000000.
serprog: requested mapping MT25QL01G is incompatible: 0x8000000 bytes at 0x00000000f8000000.
serprog: requested mapping MT25QU01G is incompatible: 0x8000000 bytes at 0x00000000f8000000.
serprog: requested mapping MT25QL02G is incompatible: 0x10000000 bytes at 0x00000000f0000000.
serprog: requested mapping MT25QU02G is incompatible: 0x10000000 bytes at 0x00000000f0000000.
serprog: requested mapping MT25QL256 is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping MT25QU256 is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping MT25QL512 is incompatible: 0x4000000 bytes at 0x00000000fc000000.
serprog: requested mapping MT25QU512 is incompatible: 0x4000000 bytes at 0x00000000fc000000.
serprog: requested mapping S25FL256S......0 is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping S25FL512S is incompatible: 0x4000000 bytes at 0x00000000fc000000.
serprog: requested mapping W25Q256.V is incompatible: 0x2000000 bytes at 0x00000000fe000000.
serprog: requested mapping W25Q256JV_M is incompatible: 0x2000000 bytes at 0x00000000fe000000.
No EEPROM/flash device found.
Note: flashrom can never write if the flash chip isn't found automatically.

undefined reference to `flash_read'

I'm attempting to build a parallel EEPROM flasher using this guide, Prototype RS232 AVR parallel flash programmer. I made the following change to enable parallel EEPROM support.

diff --git a/frser-cfg.h b/frser-cfg.h
index ef92d24..c5c8fae 100644
--- a/frser-cfg.h
+++ b/frser-cfg.h
@@ -3,9 +3,9 @@
 
 /* What kind of buses your flasher supports. I assume if it can LPC it can FWH too. */
 /* You can override that with FORCE_BUSTYPE if you cant (weirdo hardware duuude :P) */
-//#define FRSER_FEAT_PARALLEL
+#define FRSER_FEAT_PARALLEL
 //#define FRSER_FEAT_LPCFWH
-#define FRSER_FEAT_SPI
+//#define FRSER_FEAT_SPI
 
 /* Debug feature, if you want to use get_last_op to know the last frser operation. */
 //#define FRSER_FEAT_LAST_OP
@@ -22,7 +22,7 @@
 #define FRSER_NAME "frser-duino"
 
 /* Attached address lines, only if FRSER_FEAT_PARALLEL */
-//#define FRSER_PARALLEL_BITS 19
+#define FRSER_PARALLEL_BITS 19
 
 /* Ability to set SPI frequency (only if SPI). */
 #define FRSER_FEAT_SPISPEED

Unfortunately, it causes a link-time error.

avr-gcc -mmcu=atmega328p -DBAUD=115200 -Os -fno-inline-small-functions -fno-tree-switch-conversion -frename-registers -g -Wall -W -pipe -flto -fwhole-program -std=gnu99  -Ilibfrser -std=gnu99 -I. -o frser-duino.out main.c uart.c spihw.c libfrser/frser.c libfrser/udelay.c libfrser/spilib.c libfrser/spihw_avrspi.c
/usr/libexec/gcc/avr/ld: /tmp/cckuyO08.ltrans0.ltrans.o: in function `uart_send':
/home/gaizi/Code/frser-duino/uart.c:85: undefined reference to `flash_read'
/usr/libexec/gcc/avr/ld: /tmp/cckuyO08.ltrans0.ltrans.o: in function `do_cmd_opbuf':
/home/gaizi/Code/frser-duino/libfrser/frser.c:231: undefined reference to `flash_readn'
/usr/libexec/gcc/avr/ld: /tmp/cckuyO08.ltrans0.ltrans.o: in function `__vector_18':
/home/gaizi/Code/frser-duino/uart.c:47: undefined reference to `flash_write'
/usr/libexec/gcc/avr/ld: /home/gaizi/Code/frser-duino/uart.c:52: undefined reference to `flash_read'
/usr/libexec/gcc/avr/ld: /home/gaizi/Code/frser-duino/uart.c:52: undefined reference to `flash_read'
collect2: error: ld returned 1 exit status
make: *** [Makefile:62: frser-duino.out] Error 1

Apparently, it seems the parallel code is less-tested than the SPI code. What is the correct procedure to enable parallel EEPROM programming?

Also, is the information presented in the aforementioned guide still accurate? Or has the wiring has been changed in these years? I didn't find any documentation from the source code.

Compiling on windows and ubuntu

Hi.

Thank you very much for this great project.

Could you write a short guide on how to compile.
I have tried several environments, all with similar issues:

  1. Cygwin
  2. Atmel Studio
  3. Ubuntu 12.04

Thanks,
Hezi SHahmoon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.