mbox series

[v4,00/18] hw/avr: Introduce few Arduino boards

Message ID 20200120220107.17825-1-f4bug@amsat.org
Headers show
Series hw/avr: Introduce few Arduino boards | expand

Message

Philippe Mathieu-Daudé Jan. 20, 2020, 10 p.m. UTC
Hi,

This series add the arduino boards, aiming at removing the
'sample' board that doesn't follow any specification.

Since v3:
- Rebased on Michael's v41
- Drop 'extram' unused field (Igor)
- Renamed devices AVR -> Atmel (Aleksandar)
  (I haven't renamed structure names to ease review)

Since v2:
- rebased on Michael's v40

Since v1:
- Addressed Igor comments
- Addressed Aleksandar comments
- Fixed UART issue (was due to IRQ shifted by 2 in CPU)

Since Michael's work is not yet merged, Various of my patches
- which are trivials or simple renames - could be squashed
directly on his patches, if we ever care.
[I believe sending this patches is easier/quicker than keeping
asking Michael to respin his series infinitely].

Michael, do you mind testing it? The full series is available
here: https://gitlab.com/philmd/qemu/commits/arduino-v4

Regards,

Phil.

Obsoletes: <20191229224505.24466-1-f4bug@amsat.org>
Based-on: <20200118191416.19934-1-mrolnik@gmail.com>
https://www.mail-archive.com/qemu-devel@nongnu.org/msg671707.html

Philippe Mathieu-Daudé (18):
  MAINTAINERS: Move machine test to the machine section (not ARCH one)
  MAINTAINERS: Move the AVR machines in new section (not within ARM)
  tests/acceptance: Do not set the machine type manually
  tests/acceptance: Keep multilines comment consistent with other tests
  hw/char/avr: Reduce USART I/O size
  hw/timer/avr_timer16: Rename memory region debugging name
  hw/misc/avr_mask: Remove unused include
  hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
  hw/char: Rename avr_usart -> atmel_usart
  hw/timer: Rename avr_timer16 -> atmel_timer16
  hw/misc: Rename avr_mask -> atmel_power
  hw/avr: Introduce ATMEL_ATMEGA_MCU config
  hw/avr: Add some ATmega microcontrollers
  hw/avr: Add some Arduino boards
  tests/boot-serial-test: Test some Arduino boards (AVR based)
  tests/acceptance: Test the Arduino MEGA2560 board
  hw/avr: Remove the unrealistic AVR 'sample' board
  .travis.yml: Run the AVR acceptance tests

 default-configs/avr-softmmu.mak               |   2 +-
 hw/avr/atmel_atmega.h                         |  48 ++
 .../hw/char/{avr_usart.h => atmel_usart.h}    |  10 +-
 include/hw/misc/{avr_mask.h => atmel_power.h} |  11 +-
 .../timer/{avr_timer16.h => atmel_timer16.h}  |  10 +-
 hw/avr/arduino.c                              | 175 +++++++
 hw/avr/atmel_atmega.c                         | 464 ++++++++++++++++++
 hw/avr/sample.c                               | 295 -----------
 hw/char/{avr_usart.c => atmel_usart.c}        |   6 +-
 hw/misc/{avr_mask.c => atmel_power.c}         |   4 +-
 hw/timer/{avr_timer16.c => atmel_timer16.c}   |  10 +-
 tests/qtest/boot-serial-test.c                |   3 +-
 .travis.yml                                   |   2 +-
 MAINTAINERS                                   |  29 +-
 hw/avr/Kconfig                                |  11 +-
 hw/avr/Makefile.objs                          |   3 +-
 hw/char/Kconfig                               |   2 +-
 hw/char/Makefile.objs                         |   2 +-
 hw/misc/Kconfig                               |   2 +-
 hw/misc/Makefile.objs                         |   2 +-
 hw/timer/Kconfig                              |   2 +-
 hw/timer/Makefile.objs                        |   2 +-
 tests/acceptance/machine_avr6.py              |  11 +-
 23 files changed, 751 insertions(+), 355 deletions(-)
 create mode 100644 hw/avr/atmel_atmega.h
 rename include/hw/char/{avr_usart.h => atmel_usart.h} (93%)
 rename include/hw/misc/{avr_mask.h => atmel_power.h} (89%)
 rename include/hw/timer/{avr_timer16.h => atmel_timer16.h} (92%)
 create mode 100644 hw/avr/arduino.c
 create mode 100644 hw/avr/atmel_atmega.c
 delete mode 100644 hw/avr/sample.c
 rename hw/char/{avr_usart.c => atmel_usart.c} (99%)
 rename hw/misc/{avr_mask.c => atmel_power.c} (97%)
 rename hw/timer/{avr_timer16.c => atmel_timer16.c} (98%)

Comments

Philippe Mathieu-Daudé Jan. 20, 2020, 11:30 p.m. UTC | #1
On Mon, Jan 20, 2020 at 11:01 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Hi,
>
> This series add the arduino boards, aiming at removing the
> 'sample' board that doesn't follow any specification.
>
> Since v3:
> - Rebased on Michael's v41
> - Drop 'extram' unused field (Igor)
> - Renamed devices AVR -> Atmel (Aleksandar)
>   (I haven't renamed structure names to ease review)
>
> Since v2:
> - rebased on Michael's v40
>
> Since v1:
> - Addressed Igor comments
> - Addressed Aleksandar comments
> - Fixed UART issue (was due to IRQ shifted by 2 in CPU)
>
> Since Michael's work is not yet merged, Various of my patches
> - which are trivials or simple renames - could be squashed
> directly on his patches, if we ever care.
> [I believe sending this patches is easier/quicker than keeping
> asking Michael to respin his series infinitely].
>
> Michael, do you mind testing it? The full series is available
> here: https://gitlab.com/philmd/qemu/commits/arduino-v4
>
> Regards,
>
> Phil.
>
> Obsoletes: <20191229224505.24466-1-f4bug@amsat.org>

Argh the correct tag is:
Supersedes: <20191229224505.24466-1-f4bug@amsat.org>

Paolo: will this work? (replying to the cover)

> Based-on: <20200118191416.19934-1-mrolnik@gmail.com>
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg671707.html
>
> Philippe Mathieu-Daudé (18):
>   MAINTAINERS: Move machine test to the machine section (not ARCH one)
>   MAINTAINERS: Move the AVR machines in new section (not within ARM)
>   tests/acceptance: Do not set the machine type manually
>   tests/acceptance: Keep multilines comment consistent with other tests
>   hw/char/avr: Reduce USART I/O size
>   hw/timer/avr_timer16: Rename memory region debugging name
>   hw/misc/avr_mask: Remove unused include
>   hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
>   hw/char: Rename avr_usart -> atmel_usart
>   hw/timer: Rename avr_timer16 -> atmel_timer16
>   hw/misc: Rename avr_mask -> atmel_power
>   hw/avr: Introduce ATMEL_ATMEGA_MCU config
>   hw/avr: Add some ATmega microcontrollers
>   hw/avr: Add some Arduino boards
>   tests/boot-serial-test: Test some Arduino boards (AVR based)
>   tests/acceptance: Test the Arduino MEGA2560 board
>   hw/avr: Remove the unrealistic AVR 'sample' board
>   .travis.yml: Run the AVR acceptance tests
Michael Rolnik Jan. 21, 2020, 7:25 p.m. UTC | #2
Hi Philippe.

1. I cannot access https://gitlab.com/philmd/qemu/commits/arduino-v4
2. I merged your series into my workspace using patchwork
3. I payed attention that that you don't use automatic CPU detection (as
suggested by Aleksandar) by reading elf.
4. There is difference between -bios and -kernel (arduino boars crash when
-bios is used, but this seems because I run avr6 on avr5 CPU). I would be
happy if you explained what is the difference between these two arguments.
5. make check-acceptance pass correctly
6. make check-qtest-avr pass correctly


On Tue, Jan 21, 2020 at 12:01 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> Hi,
>
> This series add the arduino boards, aiming at removing the
> 'sample' board that doesn't follow any specification.
>
> Since v3:
> - Rebased on Michael's v41
> - Drop 'extram' unused field (Igor)
> - Renamed devices AVR -> Atmel (Aleksandar)
>   (I haven't renamed structure names to ease review)
>
> Since v2:
> - rebased on Michael's v40
>
> Since v1:
> - Addressed Igor comments
> - Addressed Aleksandar comments
> - Fixed UART issue (was due to IRQ shifted by 2 in CPU)
>
> Since Michael's work is not yet merged, Various of my patches
> - which are trivials or simple renames - could be squashed
> directly on his patches, if we ever care.
> [I believe sending this patches is easier/quicker than keeping
> asking Michael to respin his series infinitely].
>
> Michael, do you mind testing it? The full series is available
> here: https://gitlab.com/philmd/qemu/commits/arduino-v4
>
> Regards,
>
> Phil.
>
> Obsoletes: <20191229224505.24466-1-f4bug@amsat.org>
> Based-on: <20200118191416.19934-1-mrolnik@gmail.com>
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg671707.html
>
> Philippe Mathieu-Daudé (18):
>   MAINTAINERS: Move machine test to the machine section (not ARCH one)
>   MAINTAINERS: Move the AVR machines in new section (not within ARM)
>   tests/acceptance: Do not set the machine type manually
>   tests/acceptance: Keep multilines comment consistent with other tests
>   hw/char/avr: Reduce USART I/O size
>   hw/timer/avr_timer16: Rename memory region debugging name
>   hw/misc/avr_mask: Remove unused include
>   hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
>   hw/char: Rename avr_usart -> atmel_usart
>   hw/timer: Rename avr_timer16 -> atmel_timer16
>   hw/misc: Rename avr_mask -> atmel_power
>   hw/avr: Introduce ATMEL_ATMEGA_MCU config
>   hw/avr: Add some ATmega microcontrollers
>   hw/avr: Add some Arduino boards
>   tests/boot-serial-test: Test some Arduino boards (AVR based)
>   tests/acceptance: Test the Arduino MEGA2560 board
>   hw/avr: Remove the unrealistic AVR 'sample' board
>   .travis.yml: Run the AVR acceptance tests
>
>  default-configs/avr-softmmu.mak               |   2 +-
>  hw/avr/atmel_atmega.h                         |  48 ++
>  .../hw/char/{avr_usart.h => atmel_usart.h}    |  10 +-
>  include/hw/misc/{avr_mask.h => atmel_power.h} |  11 +-
>  .../timer/{avr_timer16.h => atmel_timer16.h}  |  10 +-
>  hw/avr/arduino.c                              | 175 +++++++
>  hw/avr/atmel_atmega.c                         | 464 ++++++++++++++++++
>  hw/avr/sample.c                               | 295 -----------
>  hw/char/{avr_usart.c => atmel_usart.c}        |   6 +-
>  hw/misc/{avr_mask.c => atmel_power.c}         |   4 +-
>  hw/timer/{avr_timer16.c => atmel_timer16.c}   |  10 +-
>  tests/qtest/boot-serial-test.c                |   3 +-
>  .travis.yml                                   |   2 +-
>  MAINTAINERS                                   |  29 +-
>  hw/avr/Kconfig                                |  11 +-
>  hw/avr/Makefile.objs                          |   3 +-
>  hw/char/Kconfig                               |   2 +-
>  hw/char/Makefile.objs                         |   2 +-
>  hw/misc/Kconfig                               |   2 +-
>  hw/misc/Makefile.objs                         |   2 +-
>  hw/timer/Kconfig                              |   2 +-
>  hw/timer/Makefile.objs                        |   2 +-
>  tests/acceptance/machine_avr6.py              |  11 +-
>  23 files changed, 751 insertions(+), 355 deletions(-)
>  create mode 100644 hw/avr/atmel_atmega.h
>  rename include/hw/char/{avr_usart.h => atmel_usart.h} (93%)
>  rename include/hw/misc/{avr_mask.h => atmel_power.h} (89%)
>  rename include/hw/timer/{avr_timer16.h => atmel_timer16.h} (92%)
>  create mode 100644 hw/avr/arduino.c
>  create mode 100644 hw/avr/atmel_atmega.c
>  delete mode 100644 hw/avr/sample.c
>  rename hw/char/{avr_usart.c => atmel_usart.c} (99%)
>  rename hw/misc/{avr_mask.c => atmel_power.c} (97%)
>  rename hw/timer/{avr_timer16.c => atmel_timer16.c} (98%)
>
> --
> 2.21.1
>
>
Philippe Mathieu-Daudé Jan. 21, 2020, 9:23 p.m. UTC | #3
On Tue, Jan 21, 2020 at 8:26 PM Michael Rolnik <mrolnik@gmail.com> wrote:
>
> Hi Philippe.
>
> 1. I cannot access https://gitlab.com/philmd/qemu/commits/arduino-v4

Oops I pushed to GitHub instead =) Now it is on GitLab too.

> 2. I merged your series into my workspace using patchwork
> 3. I payed attention that that you don't use automatic CPU detection (as suggested by Aleksandar) by reading elf.

I see, I based my work on your v38, and missed the later changes:

changes since v38
-  fix elf loader function bug introduced by prev version

And probably:

changes since v39
-  add frequency parameter to AVR timer

I'll look at Aleksandar suggestion and your last your changes, and update.

> 4. There is difference between -bios and -kernel (arduino boars crash when -bios is used, but this seems because I run avr6 on avr5 CPU). I would be happy if you explained what is the difference between these two arguments.

qemu man page is not very helpful...

       -bios file
           Set the filename for the BIOS.

       -kernel bzImage
           Use bzImage as kernel image. The kernel can be either a
Linux kernel or in multiboot format.

Paolo, Peter, do you have a simple explanation?

> 5. make check-acceptance pass correctly
> 6. make check-qtest-avr pass correctly
>
>
> On Tue, Jan 21, 2020 at 12:01 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>> Hi,
>>
>> This series add the arduino boards, aiming at removing the
>> 'sample' board that doesn't follow any specification.
>>
>> Since v3:
>> - Rebased on Michael's v41
>> - Drop 'extram' unused field (Igor)
>> - Renamed devices AVR -> Atmel (Aleksandar)
>>   (I haven't renamed structure names to ease review)
>>
>> Since v2:
>> - rebased on Michael's v40
>>
>> Since v1:
>> - Addressed Igor comments
>> - Addressed Aleksandar comments
>> - Fixed UART issue (was due to IRQ shifted by 2 in CPU)
>>
>> Since Michael's work is not yet merged, Various of my patches
>> - which are trivials or simple renames - could be squashed
>> directly on his patches, if we ever care.
>> [I believe sending this patches is easier/quicker than keeping
>> asking Michael to respin his series infinitely].
>>
>> Michael, do you mind testing it? The full series is available
>> here: https://gitlab.com/philmd/qemu/commits/arduino-v4
>>
>> Regards,
>>
>> Phil.
>>
>> Obsoletes: <20191229224505.24466-1-f4bug@amsat.org>
>> Based-on: <20200118191416.19934-1-mrolnik@gmail.com>
>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg671707.html
>>
>> Philippe Mathieu-Daudé (18):
>>   MAINTAINERS: Move machine test to the machine section (not ARCH one)
>>   MAINTAINERS: Move the AVR machines in new section (not within ARM)
>>   tests/acceptance: Do not set the machine type manually
>>   tests/acceptance: Keep multilines comment consistent with other tests
>>   hw/char/avr: Reduce USART I/O size
>>   hw/timer/avr_timer16: Rename memory region debugging name
>>   hw/misc/avr_mask: Remove unused include
>>   hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
>>   hw/char: Rename avr_usart -> atmel_usart
>>   hw/timer: Rename avr_timer16 -> atmel_timer16
>>   hw/misc: Rename avr_mask -> atmel_power
>>   hw/avr: Introduce ATMEL_ATMEGA_MCU config
>>   hw/avr: Add some ATmega microcontrollers
>>   hw/avr: Add some Arduino boards
>>   tests/boot-serial-test: Test some Arduino boards (AVR based)
>>   tests/acceptance: Test the Arduino MEGA2560 board
>>   hw/avr: Remove the unrealistic AVR 'sample' board
>>   .travis.yml: Run the AVR acceptance tests
>>
>>  default-configs/avr-softmmu.mak               |   2 +-
>>  hw/avr/atmel_atmega.h                         |  48 ++
>>  .../hw/char/{avr_usart.h => atmel_usart.h}    |  10 +-
>>  include/hw/misc/{avr_mask.h => atmel_power.h} |  11 +-
>>  .../timer/{avr_timer16.h => atmel_timer16.h}  |  10 +-
>>  hw/avr/arduino.c                              | 175 +++++++
>>  hw/avr/atmel_atmega.c                         | 464 ++++++++++++++++++
>>  hw/avr/sample.c                               | 295 -----------
>>  hw/char/{avr_usart.c => atmel_usart.c}        |   6 +-
>>  hw/misc/{avr_mask.c => atmel_power.c}         |   4 +-
>>  hw/timer/{avr_timer16.c => atmel_timer16.c}   |  10 +-
>>  tests/qtest/boot-serial-test.c                |   3 +-
>>  .travis.yml                                   |   2 +-
>>  MAINTAINERS                                   |  29 +-
>>  hw/avr/Kconfig                                |  11 +-
>>  hw/avr/Makefile.objs                          |   3 +-
>>  hw/char/Kconfig                               |   2 +-
>>  hw/char/Makefile.objs                         |   2 +-
>>  hw/misc/Kconfig                               |   2 +-
>>  hw/misc/Makefile.objs                         |   2 +-
>>  hw/timer/Kconfig                              |   2 +-
>>  hw/timer/Makefile.objs                        |   2 +-
>>  tests/acceptance/machine_avr6.py              |  11 +-
>>  23 files changed, 751 insertions(+), 355 deletions(-)
>>  create mode 100644 hw/avr/atmel_atmega.h
>>  rename include/hw/char/{avr_usart.h => atmel_usart.h} (93%)
>>  rename include/hw/misc/{avr_mask.h => atmel_power.h} (89%)
>>  rename include/hw/timer/{avr_timer16.h => atmel_timer16.h} (92%)
>>  create mode 100644 hw/avr/arduino.c
>>  create mode 100644 hw/avr/atmel_atmega.c
>>  delete mode 100644 hw/avr/sample.c
>>  rename hw/char/{avr_usart.c => atmel_usart.c} (99%)
>>  rename hw/misc/{avr_mask.c => atmel_power.c} (97%)
>>  rename hw/timer/{avr_timer16.c => atmel_timer16.c} (98%)
>>
>> --
>> 2.21.1
>>
>
>
> --
> Best Regards,
> Michael Rolnik
Richard Henderson Jan. 22, 2020, 8:46 p.m. UTC | #4
On 1/21/20 11:23 AM, Philippe Mathieu-Daudé wrote:
>> 4. There is difference between -bios and -kernel (arduino boars crash when -bios is used, but this seems because I run avr6 on avr5 CPU). I would be happy if you explained what is the difference between these two arguments.
> 
> qemu man page is not very helpful...
> 
>        -bios file
>            Set the filename for the BIOS.
> 
>        -kernel bzImage
>            Use bzImage as kernel image. The kernel can be either a
> Linux kernel or in multiboot format.
> 
> Paolo, Peter, do you have a simple explanation?

It depends on your target board.  They *can* do very different things.

E.g. for "pc" (x86) machine, -bios sets the seabios image to use, and -kernel
loads a kernel image that seabios will invoke.

E.g. for "dp264" (alpha) machine, -bios sets the palcode image to use and
-kernel loads a kernel image.  Note that in this case, the alpha kernel relies
on palcode services, so both must be present for the system to work.

E.g. for "virt" (arm) machine, -bios loads a raw image at which the reset
vector will be pointed, whereas -kernel loads a linux kernel image and follows
the arm-linux kernel boot protocol.  In other words the images are treated very
differently.

I don't know what, if anything, an avr kernel would require from boot services.
 I suspect the two options *could* be treated identically.


r~
Philippe Mathieu-Daudé Jan. 22, 2020, 9:56 p.m. UTC | #5
On 1/22/20 9:46 PM, Richard Henderson wrote:
> On 1/21/20 11:23 AM, Philippe Mathieu-Daudé wrote:
>>> 4. There is difference between -bios and -kernel (arduino boars crash when -bios is used, but this seems because I run avr6 on avr5 CPU). I would be happy if you explained what is the difference between these two arguments.
>>
>> qemu man page is not very helpful...
>>
>>         -bios file
>>             Set the filename for the BIOS.
>>
>>         -kernel bzImage
>>             Use bzImage as kernel image. The kernel can be either a
>> Linux kernel or in multiboot format.
>>
>> Paolo, Peter, do you have a simple explanation?
> 
> It depends on your target board.  They *can* do very different things.
> 
> E.g. for "pc" (x86) machine, -bios sets the seabios image to use, and -kernel
> loads a kernel image that seabios will invoke.
> 
> E.g. for "dp264" (alpha) machine, -bios sets the palcode image to use and
> -kernel loads a kernel image.  Note that in this case, the alpha kernel relies
> on palcode services, so both must be present for the system to work.
> 
> E.g. for "virt" (arm) machine, -bios loads a raw image at which the reset
> vector will be pointed, whereas -kernel loads a linux kernel image and follows
> the arm-linux kernel boot protocol.  In other words the images are treated very
> differently.
> 
> I don't know what, if anything, an avr kernel would require from boot services.
>   I suspect the two options *could* be treated identically.

I think -bios used to be dumb, and originally it would only load a 
binary blob at a fixed memory address (like mapping a ROM or a parallel 
flash).
And -kernel was a bit smarter, understanding ELF format. It can set 
(Linux) arch-specific registers, in particular when used with -append 
(cmdline) and -dtb (device tree).

At some point -bios got to understand ELF too, so QEMU could load ROMs 
mapped at different base address (and not force a default one).