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

renew core and libraries/SPI with ArduinoCore-1.8.3 #50

Closed
wants to merge 4 commits into from
Closed

renew core and libraries/SPI with ArduinoCore-1.8.3 #50

wants to merge 4 commits into from

Conversation

jg1uaa
Copy link
Contributor

@jg1uaa jg1uaa commented Sep 4, 2020

No description provided.

update core code based on ArduinoCore-avr 1.8.3

ToDo:
    - remove HID.cpp, platform.h (this code is removed at arduino-1.6.6)
      and add libraries/HID
    - create LGT8x version DigitalToggle.h and DigitalToggle.cpp,
      and remove digitalToggle() from wiring_digital.c
      (this function is supplied from
      https://playground.arduino.cc/Code/DigitalToggle/ )
mainly cosmetic changes.

- add delay(100) to DigitalPotControl.ino
- move NOP inside #if defined(__LGT8FX8P__) ~ #endif at
  transfer(void buf *, size_t count), virtually same code.
@dbuezas dbuezas force-pushed the master branch 2 times, most recently from 0dd93f9 to 26248ad Compare September 20, 2020 13:32
@dbuezas
Copy link
Owner

dbuezas commented Sep 20, 2020

@jayzakk @jg1uaa I'm not sure how to deal with this one. Will there be conflicts with eachoter's PRs?

@jayzakk
Copy link
Collaborator

jayzakk commented Sep 20, 2020

First merge jg1uaa, will take care the conflicts after.
Guess your holiday ended? It's flooding my inbox ^^

@jg1uaa
Copy link
Contributor Author

jg1uaa commented Sep 20, 2020

Oh, you have already fixed delayMicroseconds() in Wiring.h... sorry. I will fix this and push again.
Can you keep prototype definition delay(unsigned long ms) in Arduino.h?

Improved accuracy in delayMicroseconds() (#51)

* Update Arduino.h

* Update wiring.c

* Delete unnecessary files.

* Delete unnecessary files.

* Delete unnecessary files.
@jg1uaa
Copy link
Contributor Author

jg1uaa commented Sep 20, 2020

well, modifying delay() definition in Arduino.h is once cancelled (force-push is for that operation), but resolved wiring.c is still conflicted. It looks no code difference...

@jg1uaa
Copy link
Contributor Author

jg1uaa commented Oct 11, 2020

I will once close this PR, resolve conflict and re-submit again.

BTW, does anyone know how to write bootloader to LGT8F328P?
I crashed three LGT8F328P board and maybe they will be resurrected by re-flash bootloader.
LGTISP (https://github.com/brother-yan/LGTISP) could read FlashROM contents but failed to write.
I oredered SWDICE mkII Pro from TaoBao but it is not arrived yet so I cannot do anything on LGT8Fx for a short while...

@jg1uaa jg1uaa closed this Oct 11, 2020
@dbuezas
Copy link
Owner

dbuezas commented Oct 11, 2020

Awesome, thanks!

BTW, does anyone know how to write bootloader to LGT8F328P?

https://github.com/dbuezas/lgt8fx/blob/master/lgt8f/libraries/LarduinoISP/readme.md

@jg1uaa
Copy link
Contributor Author

jg1uaa commented Nov 1, 2020

I crashed three LGT8F328P board and maybe they will be resurrected by re-flash bootloader.

I got SWDICE mkII Pro and I tried to repair my LGT8F328 board.
I found that "read from FlashROM" break the content of FlashROM. Both LGTISP and SWDICE mkII, read contents of FlashROM are always 0xff and board turned to brick after read operation.

I always perform read after programming FlashROM, but veriyfing itself make things worse...

@SuperUserNameMan
Copy link
Contributor

SuperUserNameMan commented Nov 1, 2020

@jg1uaa

BTW, does anyone know how to write bootloader to LGT8F328P?
LGTISP (https://github.com/brother-yan/LGTISP) could read FlashROM contents but failed to write.

Did you use a LGT8 or an ATmega32 as ISP ?

Personally, I was confused when I tried to make an ISP using an Arduino Nano, because there seems to be different ISP projects :

Also, LGTISP wants you to connect RESET to VCC on the ISP, while LarduinoISP wants you to connect a pullup resistor to SWC ...

Very confusing.

My working combination was : Arduino Nano + .hex from LGTISP + pullup resitor from LarduinoISP.

Regarding the writing of the Booloader it works for me.

  • Into the Arduino IDE, I just select "AVR ISP" as programmer and then I just click "Burn the bootloader"

I found that "read from FlashROM" break the content of FlashROM. Both LGTISP and SWDICE mkII, read contents of FlashROM are always 0xff and board turned to brick after read operation.

It also happen to me when I dump flash using AVRDUDE and my ISP.

But when I upload a sketch using Arduino IDE and AVR ISP, it's ok.

An other issue I encounter is that, once programmed using the ISP, the LGT board starts running the sketch at the wrong clock speed and needs an hard reset.

@dbuezas
Copy link
Owner

dbuezas commented Nov 1, 2020

https://github.com/dbuezas/lgt8fx/blob/master/lgt8f/libraries/LarduinoISP/ is called LarduinoISP but it contains code from LGTISP for LGT8 only, without the .hex for ATmega328.

I updated the instructions a while back. It works well using an lgt8f328p as ISP (but follow the instructions). Do you want to make a small "tutorial" of how to use a atmega nano as ISP? :)

@SuperUserNameMan
Copy link
Contributor

It works well using an lgt8f328p as ISP (but follow the instructions).

I have not tried with a lgt8 as ISP yet because i still have unsolved serial communication stability issues with my LGT8 :-/

Do you want to make a small "tutorial" of how to use a atmega nano as ISP? :)

Not yet.
Maybe later if I find the source code of the .hex from brother-yan, or if I manage to make LGTMCU/LarduinoISP work.

@dbuezas
Copy link
Owner

dbuezas commented Nov 1, 2020

@SuperUserNameMan

Maybe later if I find the source code of the .hex from brother-yan, or if I manage to make LGTMCU/LarduinoISP work.

Isn't the source code just the same? It probably doesn't build for the Arduino nano because it requires a bigger serial buffer configured. It's defined in HardwareSerial.h as 64. Temporarily change it to 256 (in the atmel core) and it should work.

@SuperUserNameMan
Copy link
Contributor

Isn't the source code just the same? It probably doesn't build for the Arduino nano because it requires a bigger serial buffer configured. It's defined in HardwareSerial.h as 64. Temporarily change it to 256 (in the atmel core) and it should work.

Yes ! You are correct !

And updating bootloader and uploading sketches works.

Now, just have to understand why dump flash displays FF.FF.FF....
(though, reading does not brick anymore however)

@SuperUserNameMan
Copy link
Contributor

@jg1uaa :

Both LGTISP and SWDICE mkII, read contents of FlashROM are always 0xff and board turned to brick after read operation.

LGTISP/LarduinoISP dont fully implement the Cmnd_STK_UNIVERSAL command. The universal() function returns 0xFF when you dump flash using AVRDUDE.

LGTISP/LarduinoISP implementation of stk500v1 protocol is very minimal.

@jg1uaa
Copy link
Contributor Author

jg1uaa commented Nov 4, 2020

@SuperUserNameMan I see. Indeed flash_read_page() in brother-yan's LGTISP looks something incomplete. https://github.com/brother-yan/LGTISP/blob/master/LGTISP.ino#L398

And I connect WeMos TTGO XI (aka OCROBOT ALPHA) with any writer as following:

TTGO XI Programmer
SWD SWD
SWC SWC
GND GND
VIO VCC(3.3V or 5V)

This board can operate both 3.3V and 5V, but it annoys us how to apply the programming voltage to CPU. VIO pad is directly connected to LG8F328's VCC pin,

I didn't use any pull-up resistor, is this mandatory?

@SuperUserNameMan
Copy link
Contributor

@jg1uaa :

I didn't use any pull-up resistor, is this mandatory?

According to the experience i read from other users, it is optional.

I see. Indeed flash_read_page() in brother-yan's LGTISP looks something incomplete. https://github.com/brother-yan/LGTISP/blob/master/LGTISP.ino#L398

Actually, regarding usage with AVRdude, dump flash did not work because AVRdude does not sent the Cmnd_STK_READ_PAGE command that calls flash_read_page().
Instead, AVRdude sends a Cmnd_STK_UNIVERSAL command that calls the universal() function which returns the 0xFF.

I've uploaded an improved version of LarduinoISP here : https://github.com/SuperUserNameMan/LGTISP
which contains the code required for dump flash to work.
You might want to test it ?

Many functionalities are not supported (dump eeprom, write flash, eeprom, fuze etc).
I'll try to implement some of them later.

There is also a discussion on the forum : https://github.com/dbuezas/lgt8fx-forum/issues/1

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

Successfully merging this pull request may close these issues.

None yet

5 participants