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

boards: peregrine: Introduce sam4l_wm400_cape #83310

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nandojve
Copy link
Member

@nandojve nandojve commented Dec 22, 2024

The sam4l_wm400_cape is a beagle-bone cape integrated with a SAM4L SoC and RF233 IEEE 802.15.4 radio. This board has been used to validate SAM4L and write many drivers including TWIM, USB device stack and ESP-01 WiFi module. The board was developed in partnership with Universidade do Estado de Santa Catarina USFC to be used as gateway, mainly on IEEE 802.15.4 experiments developed by the Departamento de Engenharia de Automação e Sistemas EAS.

depends on #83475

@nandojve
Copy link
Member Author

Hi @kartben ,

Is not possible to attach schematic pdf files on docs folder ?

 -:79: ERROR:EXECUTE_PERMISSIONS: do not set execute permissions for source files
#79: FILE: boards/peregrine/sam4l_wm400_cape/doc/WM-400-BeagleBoneBlackShield.pdf

-:83: ERROR:EXECUTE_PERMISSIONS: do not set execute permissions for source files
#83: FILE: boards/peregrine/sam4l_wm400_cape/doc/WM-400L.pdf

@nandojve nandojve added this to the v4.1.0 milestone Dec 22, 2024
@kartben
Copy link
Collaborator

kartben commented Dec 22, 2024

Hi @kartben ,

Is not possible to attach schematic pdf files on docs folder ?

 -:79: ERROR:EXECUTE_PERMISSIONS: do not set execute permissions for source files
#79: FILE: boards/peregrine/sam4l_wm400_cape/doc/WM-400-BeagleBoneBlackShield.pdf

-:83: ERROR:EXECUTE_PERMISSIONS: do not set execute permissions for source files
#83: FILE: boards/peregrine/sam4l_wm400_cape/doc/WM-400L.pdf

I guess you should chmod u-x these files. But in any case I don't think we want to clutter git repo with PDF files and make everyone's git operations (clone, etc) slower and slower over time.
Can't you add an external link?

@nandojve
Copy link
Member Author

Hi @kartben ,
Is not possible to attach schematic pdf files on docs folder ?

 -:79: ERROR:EXECUTE_PERMISSIONS: do not set execute permissions for source files
#79: FILE: boards/peregrine/sam4l_wm400_cape/doc/WM-400-BeagleBoneBlackShield.pdf

-:83: ERROR:EXECUTE_PERMISSIONS: do not set execute permissions for source files
#83: FILE: boards/peregrine/sam4l_wm400_cape/doc/WM-400L.pdf

I guess you should chmod u-x these files. But in any case I don't think we want to clutter git repo with PDF files and make everyone's git operations (clone, etc) slower and slower over time. Can't you add an external link?

I'll drop for the moment. It can be added later.

boards/peregrine/sam4l_wm400_cape/board.cmake Outdated Show resolved Hide resolved
boards/peregrine/sam4l_wm400_cape/doc/index.rst Outdated Show resolved Hide resolved
boards/peregrine/sam4l_wm400_cape/doc/index.rst Outdated Show resolved Hide resolved
boards/peregrine/sam4l_wm400_cape/doc/index.rst Outdated Show resolved Hide resolved
Comment on lines 13 to 12

CONFIG_I2C=y

CONFIG_SPI=y

CONFIG_WATCHDOG=n
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CONFIG_I2C=y
CONFIG_SPI=y
CONFIG_WATCHDOG=n

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_WATCHDOG=n is mandatory do avoid build a warning

CMake Warning at /home/gfbudke/zephyr/mainline/zephyr/CMakeLists.txt:1002 (message):
  No SOURCES given to Zephyr library: drivers__watchdog

  Excluding target from build.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd only get that if you're building a sample which enables watchdog, and it quite rightly tells you there is no watchdog driver, so this needs to go

Copy link
Member Author

@nandojve nandojve Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true. Even the hello world shows the problem.
Maybe there is something else wrong that requires the entry.

west build -p -b sam4l_wm400_cape samples/hello_world/
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/gfbudke/zephyr/mainline/zephyr/samples/hello_world
-- CMake version: 3.25.1
-- Found Python3: /home/gfbudke/zephyr/mainline/zephyr/.venv/bin/python3 (found suitable version "3.11.2", minimum required is "3.10") found components: Interpreter 
-- Cache files will be written to: /home/gfbudke/.cache/zephyr
-- Zephyr version: 4.0.99 (/home/gfbudke/zephyr/mainline/zephyr)
-- Found west (found suitable version "1.3.0", minimum required is "0.14.0")
-- Board: sam4l_wm400_cape, qualifiers: sam4lc4b
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.17.0 (/home/gfbudke/zephyr-sdk-0.17.0)
-- Found toolchain: zephyr 0.17.0 (/home/gfbudke/zephyr-sdk-0.17.0)
-- Found Dtc: /home/gfbudke/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/gfbudke/zephyr/mainline/zephyr/boards/peregrine/sam4l_wm400_cape/sam4l_wm400_cape.dts
-- Generated zephyr.dts: /home/gfbudke/zephyr/mainline/zephyr/build/zephyr/zephyr.dts
-- Generated pickled edt: /home/gfbudke/zephyr/mainline/zephyr/build/zephyr/edt.pickle
-- Generated zephyr.dts: /home/gfbudke/zephyr/mainline/zephyr/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/gfbudke/zephyr/mainline/zephyr/build/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /home/gfbudke/zephyr/mainline/zephyr/build/zephyr/dts.cmake
Parsing /home/gfbudke/zephyr/mainline/zephyr/Kconfig
Loaded configuration '/home/gfbudke/zephyr/mainline/zephyr/boards/peregrine/sam4l_wm400_cape/sam4l_wm400_cape_defconfig'
Merged configuration '/home/gfbudke/zephyr/mainline/zephyr/samples/hello_world/prj.conf'
Configuration saved to '/home/gfbudke/zephyr/mainline/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/gfbudke/zephyr/mainline/zephyr/build/zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /home/gfbudke/zephyr-sdk-0.17.0/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/gfbudke/zephyr-sdk-0.17.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Warning at /home/gfbudke/zephyr/mainline/zephyr/subsys/usb/device/CMakeLists.txt:22 (message):
  CONFIG_USB_DEVICE_VID has default value 0x2FE3.

  This value is only for testing and MUST be configured for USB products.


CMake Warning at /home/gfbudke/zephyr/mainline/zephyr/subsys/usb/device/CMakeLists.txt:28 (message):
  CONFIG_USB_DEVICE_PID has default value 0x100.

  This value is only for testing and MUST be configured for USB products.


-- Using ccache: /usr/bin/ccache
CMake Warning at /home/gfbudke/zephyr/mainline/zephyr/CMakeLists.txt:1002 (message):
  No SOURCES given to Zephyr library: drivers__watchdog

  Excluding target from build.


-- Configuring done
-- Generating done
-- Build files have been written to: /home/gfbudke/zephyr/mainline/zephyr/build
-- west build: building application
[1/139] Preparing syscall dependency handling

[2/139] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.0.99 (/home/gfbudke/zephyr/mainline/zephyr), build: v4.0.0-2674-gf5e2680922cf
[139/139] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       24720 B       240 KB     10.06%
             RAM:       10112 B        32 KB     30.86%
           SRAM1:          0 GB         4 KB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
Generating files from /home/gfbudke/zephyr/mainline/zephyr/build/zephyr/zephyr.elf for board: sam4l_wm400_cape

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you have something enabling watchdog, it doesn't get enabled automatically, so you need to look where it's getting enabled by default (wrongly) and disable it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nordicjm ,

Look, you are judging too much without knowing the history about what you are asking for.
CC: @carlescufi , @kartben

I understand you want to have the same style and everything else perfect on Zephyr but you are forgetting about the exceptions. In fact, Zephyr as a whole is forgetting, see below:

The Atmel SAM watchdog have a history in the project and this is why it is enabled by default here, and it is not a bug:

config WATCHDOG
default y

Atmel SAM watchdog could be possible broken again due to incremental changes (not related to this PR). It will be necessary a investigation to check impact of #73091 or any other change to see if not broke the concepts agreed in the past. I'm not sure if recent changes take in consideration #23282. This is why I'm mention that require some investigation.

In the case of SAM4L. This SoC can have watchdog enabled at boot using a fuse bit (which over complicates the problem). The SAM4L SoC doesn't have the watchdog yet available on devicetree or even a driver. Besides, I wrote the code to disable the watchdog at SoC level when SoC was introduced keeping the compatibility, which was valid on that time. In the case of the board I'm adding here I do not enable watchdog at boot level. This means that it is safe always disable by default.

At end, the current state of the Zephyr project do not track correctly the requirements from the platforms and people are making mistakes all the time. It has been very difficult to track all the changes over the years without a clear requirement list. I think the situation that we found here tends to increase over the time. I'll suggest that we start to collect driver/soc requirements. I think no one wants an extended documentation but a bullet list that could point to the history of decisions and show the contradictory (the problematic ones) and the why. This way maintainers and collaborators can always check there to be sure that proposals are not violating a vendor or driver configuration. This could help when people rotate in the project too, at end, no body will live forever! Keeping this on people minds is too much IMHO.

For instance, on watchdog list:

Requirement list:
* No requirements

Exception list:
* Atmel SAM: Watchdog hardware is always enabled by default and when disabled only a power cycle can enabled it again, see #21025 #21142 #23282 #22858.
  - mandatory: watchdog MUST be always build for SAM platform. Currently it is defined at SoC Kconfigs and watchdog driver configuration should respect it. This is necessary to WDT_DISABLE_AT_BOOT work as expected.
  - mandatory: the SAM platform default board config is to disable the watchdog when some app enabled it to avoid unexpected board reboot.
  - optional: SoC's that do not implement watchdog, to avoid `no SOURCES given to Zephyr library: drivers__watchdog`, should define `CONFIG_WATCHDOG=n` at board default config.
  # The fail on this will result on a productive system that may not have a watchdog working.
  # boards can constantly reboot.

That said, I'll keep CONFIG_WATCHDOG=n at board default config. Why? Even adding the devictree, Kconfig and clean up the board we still have the No SOURCES given to Zephyr library: drivers__watchdog warning because there is no watchdog driver available.

I don't want to do workarounds on Atmel SAM. I think the correct way is finish the #23282 to gather all the requirements and then make the correct adjustments.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of SAM4L. This SoC can have watchdog enabled at boot using a fuse bit (which over complicates the problem). The SAM4L SoC doesn't have the watchdog yet available on devicetree or even a driver.

Then select the Kconfig correctly for the hardware that has it not just the wrongly with the whole family, original point remains

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is exactly your proposal?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/zephyrproject-rtos/zephyr/blob/main/soc/atmel/sam/Kconfig.defconfig#L20 move that to the series or soc defconfig files that need it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the missing driver. No need to perform changes inside SoC.
The driver solve the below 2 problems

1- the warning:

CMake Warning at /home/gfbudke/zephyr/mainline/zephyr/CMakeLists.txt:1002 (message):
  No SOURCES given to Zephyr library: drivers__watchdog

2- the wrong config:
CONFIG_WATCHDOG=n

I believe this was the right thing to do.

@nandojve nandojve requested a review from nordicjm December 23, 2024 17:36
@nandojve nandojve force-pushed the sam4l-mainline-v2 branch 3 times, most recently from be372f9 to f5e2680 Compare December 23, 2024 18:42
@nandojve nandojve force-pushed the sam4l-mainline-v2 branch 2 times, most recently from c65f19d to c701cfe Compare December 28, 2024 16:46
@nandojve nandojve requested a review from nordicjm December 28, 2024 16:48
Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs fixing as per comments

Enable sam4l internal factory calibrated RC32K clock source.  The RC32K
was used as source for Generic Clock 5 using 32 as divider.  The output
is a 1024 Hz clock that can be used by GLOC and TC0 peripherals.

Signed-off-by: Gerson Fernando Budke <[email protected]>
The Atmel sam4l have generic clock 5 enabled at 1024Hz.  Update sam4l
sam_tc_input_freq_table index 0 to reflect right value.

signed-off-by: Gerson Fernando Budke <[email protected]>
Add Peregrine Consultoria e Servicos board vendor.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Initial Version.

Signed-off-by: Gerson Fernando Budke <[email protected]>
@nandojve
Copy link
Member Author

Rebase due to #83475 was merge.

@nandojve nandojve requested a review from nordicjm January 25, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants