logo elektroda
logo elektroda
X
logo elektroda

Programming AT89S5x chips with USBasp

Mlody_Zdolny 6732 15
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • Programming AT89S5x chips with USBasp
    In older electronic equipment that has been withdrawn from use, you can find interesting elements, including various types of microcontrollers.
    Although nowadays 32-bit microcontrollers with high computing power and network interfaces are easily available for a small amount of money, sometimes an older 8-bit chip, obtained, for example, from a device intended for disposal, may be enough to implement the project.
    Particularly interesting are the 89S5x chips from Atmel. These are devices belonging to the 8051 family, equipped with an ISP interface (the letter S in the designation), which today is nothing unusual and even a norm, however, it should be remembered that other devices from this family could only be programmed in parallel (e.g. AT89C51 , not to mention non-flash versions).

    I was starting to design a DCF77 clock with a programmable controller function and I was looking for a suitable processor.
    Since I have several 89S52 systems from disassembly in my collection, I decided to use them for this purpose. In order for the development process to run in accordance with current standards, of course I wanted to use ISP for programming. It turned out, however, that all AVR programmers that I have are not able to communicate with the 89S52 in a serial way.

    Programming AT89S5x chips with USBasp

    A short web search led me to the USBasp project: https://www.fischl.de/usbasp. Within a few hours, a prototype with ATmega8 was created, mounted on a universal board. The launch went without a problem, the avrdude program detected the programmer.
    Unfortunately, when trying to read the content of 89S52, I got the following message:
    Code: Bash
    Log in, to see the code

    Something was wrong with the communication on the USBasp - AT89S52 line.
    Debugging with an oscilloscope and searching the web yielded the answer. The problem was that USBasp had a hardcoded procedure for setting the RESET pin on the ISP interface. The AVR chips have a negated RESET input, while the 89S5x chips have a non-negated input. In other words, the RESET active state for AVR is low, for 89S5x it is high.

    The author of USBasp has placed sources on his website where you can find the reason for this state of affairs:
    [syntax=c]void ispConnect() {

    /* all ISP pins are inputs before */
    /* now set output pins */
    ISP_DDR |= (1
    Attachments:

    Cool? Ranking DIY
    About Author
    Mlody_Zdolny
    Level 30  
    Offline 
    Mlody_Zdolny wrote 1438 posts with rating 632, helped 107 times. Been with us since 2022 year.
  • ADVERTISEMENT
  • #2 20541300
    Zubiik
    Level 15  
    Thanks to you, I can finally revive my procs, thanks!
  • #3 20541429
    pawlik118
    Level 33  
    Hi, can the 89LP2052 also be programmed with this modified USBasp? Is there a list of compatible chips somewhere?
  • ADVERTISEMENT
  • #4 20541514
    Mlody_Zdolny
    Level 30  
    pawlik118 wrote:
    Hi, can the 89LP2052 also be programmed with this modified USBasp? Is there a list of compatible chips anywhere?

    Hi
    I use avrdude version 6.3-20171130 to operate the programmer.
    Unfortunately, the list of supported microcontrollers does not include the one you are asking about.
    In general, the case looks dull, because this list contains only one type from the 89x family
    Valid parts are:
      uc3a0512 = AT32UC3A0512
      8052     = AT89S52
      c128     = AT90CAN128
      c32      = AT90CAN32 (...)

    Newer versions of avrdude, including the latest 7.1, no longer support any of the older CPUs from what I can see.

    The programmer itself would probably be able to program it, but you would have to add such functionality to avrdude.
    Perhaps other software is able to program, but I do not know one.
  • ADVERTISEMENT
  • #5 20541544
    gulson
    System Administrator
    Great, write to me for a small gift.
  • #6 20541669
    ArturAVS
    Moderator
    A few years ago I managed in a simpler way (as for me), I added a single 74HC1G14 gate and a jumper that switches the RESET signal (typical or negated depending on the programmed uC).
  • #7 20541930
    Mamut
    Level 18  
    erm... Some time ago I made this firmware:
    https://github.com/mamut-tme/UsbAsp-flash_89S52

    Support for s51 and s52 works in it without any problems.

    Patch speeding up sck (it's more for AVR, s51/52 doesn't work with such a fast clock) for avrdude has been merged into the main repo in the meantime. It was a project I made during covid self-isolation, unfortunately my only target at89s52 died at the end, so I didn't have time to optimize everything.
  • #8 20546436
    Wirnick
    Level 30  
    @Mlody_Zdolny I downloaded your sources and put together the project with the original files, but it doesn't compile in Eclipse.
    Even the original projects don't compile - something is missing (and I'm definitely low on oil).
    Screenshot of a compilation error in Eclipse for an AVR project.
    I'll add more points for your project's binary to resuscitate some old CPUs.
    I will be grateful if you share the results of your work.
  • #9 20546567
    Mlody_Zdolny
    Level 30  
    @Wirnick I am compiling in my linux environment (Mint Vera 21.1) using the latest versions of tools around gcc and avr. I use Makefile to compile by running the following command in the firmware directory:

    Code: Bash
    Log in, to see the code
  • #10 20546627
    Wirnick
    Level 30  
    @Mlody_Zdolny thank you very much for your response, but the .hex file is independent of the development environment. I am currently programming in MPLAB (after the acquisition of Atmel by Microchip). I'm going into the new without forgetting about the history of e-waste. In our case, the hexe is determined by avrdude.
  • ADVERTISEMENT
  • #11 20546667
    Mlody_Zdolny
    Level 30  
    Wirnick wrote:
    but the .hex file is development environment independent

    Yes, but the tools with which hex is created depend on the environment. There are versions for Linux and Windows, so I gave a short description of my configuration. MplabX can use xc8, but so can gcc. Avrdude, on the other hand, is a program that supports the USBasp programmer using USB control commands.
  • #12 20546779
    Wirnick
    Level 30  
    As usual, I turned around. I was thinking AVR Toolchain and wrote avrdude. Am I to understand that you will no longer share the fruits of your labor?
  • #13 20546838
    Mlody_Zdolny
    Level 30  
    Wirnick wrote:
    Am I to understand that you will no longer share the fruits of your labor?

    I can share the hex, but in general I think that the sources carry more value, because everyone can change something according to their needs. I'll send something tonight.

    Perhaps the compilation problem is in the usbdrv.* files where you just need to add 'const', for example:
    PROGMEM const char usbDescriptorString0[].
    I attach files with this modification and hexa.
  • #14 20547726
    Mamut
    Level 18  
    hex to my firmware variant (link above). It does not require any modification of the original USBasp schema.
    Detecting whether it is s5x or avr is automatic. Target initialization tries AVR first, then s5x. Comments in the code may look strange, but it's a combination of two different solutions, there is also i2c and spi (and microwire?) support for serial memory (there is software on the repo, but to be honest, I haven't checked it).
  • #15 20548000
    Wirnick
    Level 30  
    @Mlody_Zdolny thank you very much and you are my Friend!
    I have achieved success as shown in the attached picture. I made a correction in the #include paths in the file main.ci usbdrv.h and in the file clock.h I changed to //#define F_CPU 12000000L /* 12MHz */ . At the same time, the file.eep is created, which also needs to be uploaded to AT8 (I think).

    Programming AT89S5x chips with USBasp

    I am building a programmer.
    Regards
    Wirnick

    @Mamut I am also interested in your project due to the ability to read and program very many circuits. I am programming in Delphi 10.1 Berlin. Is it possible to transfer your program project to my platform?
  • #16 20548804
    Mamut
    Level 18  
    Wirnick wrote:
    @Mamut I am also interested in your project due to the ability to read and program very many circuits. I am programming in Delphi 10.1 Berlin. Is it possible to transfer your program project to my platform?

    Unfortunately, I can't help much with that. As it says in the github repo description, my code is a combination of a solution from some nofeletru (from Moscow) and Miles McCoo (from a defunct site, but you can still access it via archive.org). I modified many parts of the code from Miles, because the s5x support was quite slow and that's what I mainly worked on - I added paged mode reading (checked) and paged mode (unchecked) and a few other improvements based on the analysis of documentation from AT89S51/52. However, from the code from nofeletru I "gave" 3 MHz SCK for AVR (original USBasp does not have it) and added my own 6 MHz, but it will only work with 20 MHz quartz chips, and after changes in procs, as they were still Atmela, I do not know if some others can work with this frequency (once I think ATTiny2313 could, there were others, but I don't remember). I haven't touched the serial memory part, it's unchanged.
    As I wrote, it was a "covid" project for me, I had some elements at home and I made use of them. Then the only S52 died, I went back to work and the project went into a drawer.

Topic summary

The discussion revolves around programming AT89S5x microcontrollers from Atmel using a USBasp programmer. Users share experiences and solutions for reviving older microcontrollers, particularly focusing on the compatibility of various chips with the USBasp and avrdude software. One user inquires about programming the 89LP2052 chip, but it is noted that avrdude's support for older microcontrollers is limited. Several users contribute by sharing firmware modifications and compilation tips, including a GitHub repository for USBasp firmware that supports AT89S52. The conversation highlights the challenges of compiling code in different environments and the importance of source code for customization. Users express gratitude for shared resources and successful programming outcomes.
Summary generated by the language model.
ADVERTISEMENT