-
Notifications
You must be signed in to change notification settings - Fork 145
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
AT89S51 and AT89S52 support for avrdude #1304
Comments
Hi! First of all, Avrdude doesn't support programming of AT89 chips out of the box, but with a custom avrdude.conf file it might work. First, can you share the part of your avrdude.conf where the AT89S52 chip is defined? |
Thanks for the reply! The error message complains about the programmer type! I did try the original installation as well, without the updated config file, with another programmer, and with another device that were in the original config file, and got the same error message about the programmer type. Enclosing the config file section about the AT89S52. Thanks, Peter
|
It might be something else that's wrong with your avrdude.conf. I'm using the latest 7.1 version, and I'm able to get Avrdude to run even though there are a few warnings. Try building Avrddue yourself, and add the AT89S52 target to the avrdude.conf file that was created by the build.
|
Since this is not supported by avrdude, I will close this issue. The command line mentioned in the first post is totally wrong. It should be |
Even though avrdude doesn't support AT89S series, for coherence, the 7.1 should behaviour the same as 7.0 which works well.
It seems that 7.1 couldn't analyse the old avrdude.conf well, and throwed out the error:
Anyway, for convenience I strongly recommand to keep the coherence with 7.0. |
BTW, I have tried to update the avrdude.conf as below to fit 7.1:
And I got another error. Since I know nothing about the a1 bit, any advice?
|
No, the warnings will be there if you use old-style avrdude.conf file. And to me it is not worth the effort to support AT89S52 in avrdude. |
That being said, maybe @MCUdude or @stefanrueger will be able to see if they can help you here or not. |
Hmm, it seems to be that PlatformIO seems to support AT89S51/AT89S52 using avrdude. So maybe there are valid use case here. I will leave this to other admins to decide. Therefore I have re-opened the issue and changed the issue titile and the issue label to "enhancement". |
Try the following entries [edit: added prog_modes]
One problem with this part is the odd documentation for the read-signature command (see below); it claims to utilise A7..A12, but that cannot be because signatures have 3 bytes, so only A0 and A1 should be relevant. I suspect the documentation is wrong, and that A0 and A1 need to be set. I looks like this part has A0 and A1 not in their standard position (end of Byte 3) but instead at end of Byte 2. All other parts known to AVRDUDE have the address bits in byte2 and byte3 in a systematic way, which has allowed a new shorter syntax for the command. So the read signature command for AT90S51/52 must use the old-style notation. Fun fact: It used to be that contributors could not cope with the old-style notation to the effect that some 25% of the avrdude.conf entries had bits in the wrong position. This is why the warning message has been introduced. It can be ignored in this case (assuming A0/A1 have to be at the unsystematic position for these parts). |
@orbanp: The avrdude command mixed up the
Please try again and report back. |
@stefanrueger, THX. I have tried your new avrdude.conf, but unluckly it didn't work:
BTW, in the same environment, V7.0 with this old avrdude.conf works well:
|
@llinjupt Thanks for sharing a working 7.0 entry. My guess was based on @orbanp's entry. It might have been the missing
|
@stefanrueger Good news it works and bad news with warninings:
|
This is the first time the project has come across an AVR where the address bits do not conform to their usual positions. When we create a PR to support AT89S51/52, we can try to suppress the warning for these (odd) parts. Before I do a PR, please also try to write flash and verify. If you have the AT89S51, please also try that part. BTW, in order to migrate a part entry from an older avrdude version, you can normally put that into avrdude.conf, add new parameters needed for the new version (here,
This outputs migrated, canonical entries suitable for the new version. I also noted that the flash r/w commands have one address bit too many: it's word addresses, not byte addresses for flash. This should be better [edit - also updated stk500_devcode for the AT89S51]:
|
@stefanrueger , Yes, you are right that AT89S51 has its own devcode. And I have checked how it is used. Actually, in avrisp, it's only used to detemine the rst polarity, and that's why the old avrdude.conf is accidentally ok for AT89S51:
Reading back the flash and fill it up to the full falsh size: Wrting failed with your lastest avrdude.conf and check the datasheet there is really an A12 which seems can be ignored:
There is no AT89S51 on hand, so I have ordered some chips already. Maybe two or three days the feedback will be ready. Another subtle problem is that I have noticed the lock bits in the datasheet as well as the picture you pasted above. For reading there are 3 bits LB3/2/1 and for writing there are 2 bits B1/B2. Isn't it a bit confusing? Would you like to config it too for both 51/52 in avrdude.conf? And I could verify at the same time. |
Thanks for testing. I suspect for writing to work the flash memory should specify the correct Maybe try, 2, 4, 8, 16, ... It is a pity there does not seem to be an .atdf file (or .xml file as they were called in the early days) containing the necessary write delay etc parameters that need to go into the .conf file. The data sheet is very terse, too. In order for HVPP programming to work, other parameters would need to be specified, too, in avrdude.conf. Maybe try setting the other parameters like in @orbanp 's entry? Or copying parameters from "similar" other parts in avrdude.conf for this entry? You could try a few settings. I suspect AVRDUDE will be able to read the lock bits but won't be able to write them: The .conf file can set pretty much any SPI command (the old notation has a very versatile syntax!), but apparently the footnote in the data sheet says that one needs several writes of different SPI-commands to effect certain lock levels... That procedure isn't in the code base (and is probably not worth our while implementing!) |
Ooops that's right. And the data sheet says "byte mode" for flash r/w. So, page size 1 would appear correct for flash. And one would need a12 in the flash read/write commands (as it's a byte address not a word address). So, this makes me wonder. Has your .conf file also worked for writing in AVRDUDE v7.0 or any earlier AVRDUDE? If so let us know. |
Here another one to try with some sensible other values set
|
I see. If the code base don't suppport, it's reasonable and acceptable.
Yes. I have tried 6.3 and it worked well. With your newest avrdude.conf, both reading and writing are passed for 89S52. And as soon as 89S51 is arrived I will give feedback.
|
Yes, the address space is exactly the same as the flash size. And I have noticed AT89S51/2 all support page mode read/write. Is it possible to support it? If so, it would be great for speed consideration. |
Hello Everyone, I appreciate the continuing help and discussions! To reiterate, I have avrdude version 3.6 on my machine, ubuntu 20.04 with KDE frontend. I have two hardware interfaces for programming. One of them is a pair of usbasp dongles. The usbasp interfces do work, I did upgrade the firmware in them, programming one with the other. It was a couple of years ago when I obtained them on ebay, not sure about the firmware version. The other interface is a simplified version of the STK200 dongle, a cable from the parallel port of the PC, with four simple wires for the reset, in and out data, and clock signals, plus ground. Looking at the signals with a scope, using the usbasp interface, that hardware does not handle the reset signal. The AT89S52 has an active high reset, and it needs to be set to high to initiate ISP programming and the usbasp interface does not do that. "My STK200" dongle shows some life when trying to program. Again, here is the processor description in the config file that I have been using with avrdude 6.3:
Also enclose the STK200 description with the inverted reset:
Thanks, Peter |
@orbanp @mcuee Spending some time doing hacking, I found it's easy to make the official USBasp version to support avrdude:
Keep in mind that you only need to do 2 things:
Since I didn't hack it on a AVR MCU, so I paste alike hacked code below for you to refer:
|
Thanks a lot for looking at usbasp firmware. This is much better for avrdude project. It is always better to support open firmware and not some unknown firmware. I will try your modification once I get the AT89S52 chip. @dioannidis |
Hi,
OK I'll order those parts and after testing I'll add it |
In this case, it is possible to just change avrdude (to change usbasp.c and avrdude.conf.in, create a variant of usbasp, say, usbasp_at89s) without changing the usbasp open source firmware? I have also re-opened this issue to see if there is a way to support these two AT89S chips with other programmers, at least for a few more popular ones. I am guessing STK500v2 based programmers may already work. I am not so sure about USBtinyISP. Edit: adding a reference here: reset pin polarity handling can be done by HW as well. |
@mcuee
|
I agree with @llinjupt: this is probably nothing AVRDUDE can do about it if the programmer cannot cope with different reset polarity. I suggest closing the issue again. |
Okay, close for now. |
The AT89S51 and AT89S52 ICs just arrived :) . Do I need a patched avrdude and conf file or the version from here https://github.com/mcuee/avrdude/releases/tag/v7.1 supports them ? I'll try to find time next week to test the llinjupt's code and if all is ok then I'll release the 1.11 version . |
I think the idea is not to patch avrdude, but rather patch usbasp FW. You can use the latest github action mingw-64 build of avrdude main. |
You can also use my mingw64 build if you prefer. |
I'll try both ;) ... Thx ! |
Both avrdude mingw64 builds ( yours and avrdude main ) are working fine with the composite firmware ! Thx ! |
Wondeful. I will try your modified FW once I get the AT89S52 chip. |
< snip > Fortunately for the USBasp improved firmware to support the AT89S51/2 ICs only the following lines has to be added to ispEnterProgrammingMode() :
|
< snip >
As I don't use MCS-51 MCUs, I adapted a basic blink assembly program and used the Microchip's c51asm assembler to produce a 27 bytes binary . Please if it's possible test it with a bigger binary to see if there is a problem . |
That file will be deleted . Please use the firmware binaries from the 1.11 pre release from today ! I re uploaded them, because they were corrupted :( See Corrupted firmware binaries in 1.11 pre Release assets |
Thanks. I just got AT89S51 chip. The first test shows it works well.
|
Please give the FW from @dioannidis a try. It seems to work pretty well. I am using latest avrdude git main (built using MSYS2 mingw64). |
No issues with AT89S52 as well.
|
Sorry for the late reply, I was away travelling. Writing the AT89S52 chip is working now, however, reading back the code from the chip I get something different! As mentioned reading back the written code from the chip results in something different, writing it back again the processor does not work as it is supposed. Thanks, Peter |
Could you please test with the -B x option ( i.e. -B9 or -B11 ) ?
There is a bug that I couldn't find time to tackle yet .... Error in read after entering PE with slow clocks |
The chip runs at 12MHz.Reading the chip with the -B9 or -B11 option the read files are identical, though they are different from the one read without the -B option.Writing back the "-B11" read file the code works. (Did not test with the "-B9" file.)
So it looks like for the correct reading the speed option is required.
Thanks, Peter
On Saturday, June 3, 2023 at 04:06:33 p.m. EDT, dioannidis ***@***.***> wrote:
@orbanp
Could you please test with the -B x option ( i.e. -B9 or -B11 ) ?
1 /* 500 Hz */
2 /* 1 kHz */
3 /* 2 kHz */
4 /* 4 kHz */
5 /* 8 kHz */
6 /* 16 kHz */
7 /* 32 kHz */
8 /* 93.75 kHz */
9 /* 187.5 kHz */
10 /* 375 kHz */
11 /* 750 kHz */
12 /* 1.5 MHz */
There is a bug that I couldn't find time to tackle yet .... Error in read after entering PE with slow clocks
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Can you test with this fw ( Tested with an atmega8 with hfuse 0xD9 and lfuse 0xE1 ) regards |
It is working!
I installed v1.11 into the usbasp.I changed in the Makefile the line from "ISP=snap_isp" to "ISP=usbasp".
The read function initiates the SCK frequency to 32kHz.The read of the flash and writing it back works OK.
Interestingly, the verification (read) part of the flash writing is a lot faster than the single flash read function.
I would like to thank everyone to make the AT89S52 programming with avrdude and usbasp working!
Regards, Peter
|
How do you know that it starts with a 32kHz sck frequency ? You used the avrdude's -B option ? If you did please test without it . The USBasp's probe function should start with a SCK frequency of 1.5 MHz, trying 3 times ( for both AVR and AT89S* , so it's a little bit slower ), going lower if it didn't get a valid response .
I'm glad that it worked ! PS: ( If your USBasp device exposes the RxD/TxD signals to the connector, you can test the HID UART functionality of the firmware using the USBaspHIDUART utility. See also UART HID protocol ) . regards, |
Leaving out the speed option the reading and writing still works OK!You are correct, I accidentally left in the speed option from yesterday, I have saved the avrdude commands for testing in a text file.
According to the documentation usbasp does have the RXD/TXD signals at the ISP connector, however the board (a kit) with the AT89S52 chip does not have those signals connected. I guess I could put those in if I wanted...
The kit originally came with a Chinese STC clone processor, that uses a different programming protocol from Atmel's using the RXD/TXD signals. I replaced the STC chip with the Atmel processor.
I guess I could test the USBaspHIDUART utility with that STC chip too.Programming the STC chips there is also the stcgal tool for that (I have not used it).
Regards, Peter
On Monday, June 5, 2023 at 07:40:38 a.m. EDT, dioannidis ***@***.***> wrote:
@orbanp, @mcuee
The read function initiates the SCK frequency to 32kHz.
How do you know that it starts with a 32kHz sck frequency ? You used the avrdude's -B option ? If you did please test without it .
The USBasp's probe function should start with a SCK frequency of 1.5 MHz, trying 3 times ( for both AVR and AT89S* , so it's a little bit slower ), going lower if it didn't get a valid response .
It is working!
I'm glad that it worked !
PS: ( If your USBasp device exposes the RxD/TxD signals to the connector, you can test the HID UART functionality of the firmware using the USBaspHIDUART utility. See also UART HID protocol .
regards,
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hello Everyone,
I am new here, so please advise if this is the wrong place to ask the following question.
I am trying to program an AT89S52 chip.
I am using avrdude 6.3 and an ebay programmer which is a version of the usbasp programmer.
The OS is Kubuntu 20.04 LTS.
I am getting the following error message:
I updated the configuration file that has an entry for the AT89S52 chip, the programmer description is the same that came with the installation.
The suggestion that the programmer type should be written in the configuration file with double quotes did not make any difference.
Previously I installed avrdude 7.0 and got the same error.
avrdude 6.3 came from the Software Center of the OS.
Any help would be appreciated!
Thanks, Peter
The text was updated successfully, but these errors were encountered: