Commit Graph

110 Commits

Author SHA1 Message Date
Doug Brown
b2088148ff Add initial hardware.h for M258KE
Delay functions aren't implemented yet; they will be coming later.
2023-06-25 11:41:19 -07:00
Doug Brown
4bda68346f Add implementation of ParallelBus for M258KE 2023-06-25 11:41:19 -07:00
Doug Brown
ce5e2e97a3 Add ability for status LED to be inverted 2023-06-25 11:41:19 -07:00
Doug Brown
47155a7e7d Add GPIO driver
Provide the basic functionality for setting direction, turning on and
off, toggling, reading inputs, and enabling/disabling pullups.

This chip also provides pulldowns, so in the future I will also
implement pulldown control so we can detect shorts to 5V.
2023-06-25 11:41:19 -07:00
Doug Brown
dd4910caeb Implement stubbed-out SPI driver
SPI isn't needed on this platform because we don't need an I/O expander.
So this can be a bunch of stub functions that do nothing. They will be
optimized out during the linking process anyway.
2023-06-25 11:41:19 -07:00
Doug Brown
085f8c05d6 Add cmake toolchain file for M258KE build 2023-06-25 11:41:19 -07:00
Doug Brown
7d83075f10 Add USB CDC serial port code
This implements a USB CDC serial port using the Nuvoton USBD driver. The
USB handling is based on Nuvoton's BSP sample code, especially the IRQ
handlers and descriptor buffer configuration. The descriptors have been
adapted to be similar to the AVR version, and RX/TX functions have been
written to implement an API closer to LUFA, which is what the SIMM
programmer common code needs.
2023-06-25 11:41:19 -07:00
Doug Brown
7dd0f3f9db Include usbd.h
Since I stripped the peripheral header includes from M251.h, I have to
include it manually instead.
2023-06-25 11:41:19 -07:00
Doug Brown
5fbc982c31 Fix const correctness of S_USBD_INFO_T struct 2023-06-25 11:41:19 -07:00
Doug Brown
ce8932e80f Disable unnecessary interrupt
I don't really need to bother with VBUS or "no-event-wake-up"
interrupts. This allows me to strip out more code in the IRQ handler.
2023-06-25 11:41:19 -07:00
Doug Brown
c50da81d8c Change USBD_MemCopy to not be static inline
I'm sure it's slightly more efficient as a static inline function, but
it results in less flash usage as a separate function. This is important
for the bootloader where every byte matters.
2023-06-25 11:41:19 -07:00
Doug Brown
5fc45624ef Strip out unnecessary callbacks and code in USBD driver
This is important for the bootloader. There's a bunch of stuff here we
don't need that unnecessarily bloats the code.
2023-06-25 11:41:19 -07:00
Doug Brown
257d395cd2 Bypass GCC built-in startup code
Nuvoton's sample startup_M251.S file handles enough initialization for
my purposes, so I can completely bypass _start and jump directly to
main. Note that I also had to add a define to enable clearing of BSS.
2023-06-25 11:41:19 -07:00
Doug Brown
71af23b33e Strip out unnecessary clock and UART code
The default values for SystemCoreClock, CyclesPerUs, and PllClock work
fine for my purposes of running from the 48 MHz HIRC. Remove unnecessary
initialization code. This is especially useful for the bootloader where
flash space is at a premium.

Also strip out unneeded UART setup code.
2023-06-25 11:41:19 -07:00
Doug Brown
3a7e3bf69f Don't include peripheral header files in M251.h
I don't want to include all of Nuvoton's peripheral drivers, but I do
want to use this header file. Remove the unnecessary peripheral
includes.
2023-06-25 11:41:19 -07:00
Doug Brown
9f0299a9c4 Reserve 4 bytes at end of RAM for magic number
This will be used during firmware updates so that the main firmware can
communicate to the bootloader that it should stay in the bootloader for
a firmware update rather than run the main firmware again.
2023-06-25 11:41:19 -07:00
Doug Brown
7c368aa816 Fix issue with linker script allowing data section to overflow flash 2023-06-25 11:41:19 -07:00
Doug Brown
7a77d583da Update linker scripts with correct RAM/flash sizes
Change code style so that it's easy to see the number of kilobytes too.
2023-06-25 11:41:19 -07:00
Doug Brown
e1e1523a99 Add README explaining the Nuvoton directory 2023-06-25 11:41:19 -07:00
Doug Brown
30e8baef89 Initial commit of Nuvoton USBD driver 2023-06-25 11:41:19 -07:00
Doug Brown
979f531bdf Initial commit of register defines, CMSIS code from Nuvoton BSP 2023-06-25 11:41:19 -07:00
Doug Brown
2e4e303c0c Change license to GPLv3
I can't use GPLv2 as soon as I need to start using the Nuvoton sample
code which is licensed with an Apache 2.0 license.
2023-06-25 11:41:18 -07:00
Doug Brown
8f3c74a14e Update copyright date 2023-06-25 11:38:41 -07:00
Doug Brown
7851bb2d10 Update README with build instructions
This README contains an overall summary of the entire project, but it
was missing build instructions for the firmware. Add them now that cmake
is all set up.
2023-06-25 11:38:41 -07:00
Doug Brown
afeeb5bfe7 Ignore CMakeLists.txt.user generated by Qt Creator 2023-06-25 11:38:41 -07:00
Doug Brown
bf1031127d Set up CMake build
This allows building with CMake instead of Eclipse. The reasoning behind
this is to make the code more easily portable to other architectures,
and to move away from being dependent on Eclipse.
2023-06-25 11:38:41 -07:00
Doug Brown
174bcdb370 Add CMake toolchain for AVR compilation 2023-06-25 11:38:41 -07:00
Doug Brown
baf0937589 Switch to config header for LUFA
This eliminates the need for a bunch of extra defines added to the
compile command.
2023-06-25 11:38:41 -07:00
Doug Brown
b627ef9020 Move descriptors to RAM
This ensures they will work properly on the AT90USB128x, especially in
the bootloader where they will be in the upper 64 KB.
2023-05-28 19:34:02 -07:00
Doug Brown
3a8e006925 Manually control USB PLL
The 646 and 1286 have different required USB PLL values when you have a
16 MHz crystal. Detect the chip at runtime to set up the PLL correctly.
This requires taking over control of the PLL from LUFA.
2023-05-28 19:34:02 -07:00
Doug Brown
88e8f47bde Jump to correct bootloader address based on whether it's a 64x or 128x 2023-05-28 19:34:02 -07:00
Doug Brown
a7fe6d9b39 Add utility function for determining the AVR model
This is needed in order to handle slightly different functionality
between the AT90USB64x and AT90USB128x.
2023-05-28 19:34:02 -07:00
Doug Brown
14cf8505f7 Break out bootloader entry into HAL
For some reason, I didn't have this as part of the HAL, so the main
program still had AVR dependencies.
2023-05-28 19:34:02 -07:00
Doug Brown
8aec8807c9 Fix line endings
A whole bunch of files in this project had DOS line endings. This is due
to how I started working on it on a Windows machine with little Git
experience. Now it's inconsistent so I'm fixing it.
2023-05-28 19:34:02 -07:00
Doug Brown
82df6ea459 Fix a few minor issues
I noticed that after I implemented the SPI optimization of cycle
counting instead of polling on SPIF, the first "normal" SPI transaction
I tried would fail. This is because nothing was clearing the SPIF flag
anymore, and the normal SPI driver still looks at it. So it was thinking
that the latest transaction was already completed (it wasn't). Worked
around this by making sure we clear the flag in SPI_Assert. I'm not
concerned about performance impact here because the actual clean SPI
driver is not used in performance-bound situations.

Fixed an issue that identified the wrong pins as shorted to ground in
the electrical test functionality. Whoops!
2020-11-27 00:16:35 -08:00
Doug Brown
39f34d67c4 Fix some spaces that should have been tabs 2020-11-27 00:16:35 -08:00
Doug Brown
9e586339dd Insane SPI optimization
Wait a specific amount of time after each SPI transfer instead of
polling status. It works, and it saves about 21 seconds in total on an
8 MB SIMM!
2020-11-27 00:16:35 -08:00
Doug Brown
4394533d88 Small optimization to address calculation
Due to integer promotion, the calculation of what to write to PORTD was
inefficient. Based on my benchmarking, it didn't really matter though.
2020-11-27 00:16:35 -08:00
Doug Brown
9521494971 Optimize read/write cycle functions
If multiple read or write cycles are done in sequence, we'll no longer
needlessly update the data direction registers (which is a slow SPI
transaction). We can also skip updating the pullups on the AVR if
multiple read cycles occur in sequence.
2020-11-27 00:16:35 -08:00
Doug Brown
2943b80c42 Optimize reading of 1024 byte chunks
This was a suggestion from bigmessowires. Do a tight loop when reading
a chunk of 1024 bytes. It's faster.
2020-11-27 00:16:35 -08:00
Doug Brown
3df4c40f38 Add/update copyright
This just makes sure everything is up to date with copyrights.
2020-11-27 00:16:35 -08:00
Doug Brown
7425af761a Break out code into a HAL, optimize flash operations
This makes the code pretty easily portable to other architectures if someone
wants to make a more modern SIMM programmer. I also was pretty careful to split
responsibilities of the different components and give the existing components
better names. I'm pretty happy with the organization of the code now.

As part of this change I have also heavily optimized the code. In particular,
the read and write cycle routines are very important to the overall performance
of the programmer. In these routines I had to make some tradeoffs of code
performance versus prettiness, but the overall result is much faster
programming.

Some of these performance changes are the result of what I discovered when
I upgraded my AVR compiler. I discovered that it is smarter at looking at 32-bit
variables when I use a union instead of bitwise operations.

I also shaved off more CPU cycles by carefully making a few small tweaks. I
added a bypass for the "program only some chips" mask, because it was adding
unnecessary CPU cycles for a feature that is rarely used. I removed the
verification feature from the write routine, because we can always verify the
data after the write chunk is complete, which is more efficient. I also added
assumptions about the initial/final state of the CS/OE/WE pins, which allowed me
to remove more valuable CPU cycles from the read/write cycle routines.

There are also a few enormous performance optimizations I should have done a
long time ago:

1) The code was only handling one received byte per main loop iteration. Reading
   every byte available cut nearly a minute off of the 8 MB programming time.
2) The code wasn't taking advantage of the faster programming command available
   in the chips used on the 8 MB SIMM.

The end result of all of these optimizations is I have programming time of the
8 MB SIMM down to 3:31 (it used to be 8:43).

Another minor issue I fixed: the Micron SIMM chip identification wasn't working
properly. It was outputting the manufacturer ID again instead of the device ID.
2020-11-27 00:16:35 -08:00
Doug Brown
927c178671 Ignore local settings files. Get project compiling on my computer. 2020-11-27 00:16:35 -08:00
Doug Brown
2c3202af3b
Update README.md
Updating in preparation for latest release. Changed a few descriptions and removed some unrelated things.
2020-11-26 23:41:14 -08:00
Doug Brown
4e9ee40aaa Merge pull request #26 from steve-chamberlin/master
Added AVR Studio project file for SIMM Programmer firmware
2016-04-25 17:59:11 -07:00
steve-chamberlin
d1f80fe9c5 Added AVR Studio project file for SIMM Programmer firmware 2016-04-25 13:48:59 -07:00
Doug Brown
c10a164359 Merge pull request #25 from jpluimers/master
Wiki updates (images, links); added README.md to master branch; added downloads branch.
2015-10-11 13:26:40 -07:00
Jeroen Pluimers
1200bcae06 README as a starting point to the repositories and other documentation. 2015-10-10 17:30:55 +02:00
Doug Brown
e2963070bc Added ability to tell programmer firmware to selectively unlock chips. 2013-07-04 12:10:18 -07:00
Doug Brown
0ebb9d2281 Finished implementing protocols for reading/writing portions of the SIMM 2012-10-17 21:31:00 -07:00