Implemention of RTEMS-libbsd FDT support for BBB

The previous blog article describes how to implement FDT on RTEMS. This article will show you how to implement FDT support on RTEMS-libbsd.

The implementation of the rtems-libbsd management bus is in the nexus-devices.h file, that is, rtemsbsd/include/bsp/nexus-devices.h

  1. /* 
  2.  * Copyright (c) 2013-2015 embedded brains GmbH.  All rights reserved. 
  3.  * 
  4.  *  embedded brains GmbH 
  5.  *  Dornierstr. 4 
  6.  *  82178 Puchheim 
  7.  *  Germany 
  8.  *  <rtems@embedded-brains.de> 
  9.  * 
  10.  * Copyright (c) 2016 Chris Johns <chrisj@rtems.org> All rights reserved. 
  11.  * 
  12.  * Redistribution and use in source and binary forms, with or without 
  13.  * modification, are permitted provided that the following conditions 
  14.  * are met: 
  15.  * 1. Redistributions of source code must retain the above copyright 
  16.  *    notice, this list of conditions and the following disclaimer. 
  17.  * 2. Redistributions in binary form must reproduce the above copyright 
  18.  *    notice, this list of conditions and the following disclaimer in the 
  19.  *    documentation and/or other materials provided with the distribution. 
  20.  * 
  21.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
  31.  * SUCH DAMAGE. 
  32.  */  
  33.   
  34. #if !defined(BSP_NEXUS_DEVICES_h)  
  35. #define BSP_NEXUS_DEVICES_h  
  36.   
  37. #include <bsp.h>  
  38.   
  39. #include <rtems/bsd/bsd.h>  
  40. #include <machine/rtems-bsd-nexus-bus.h>  
  41.   
  42.   
  43. #if defined(LIBBSP_ARM_REALVIEW_PBX_A9_BSP_H)  
  44.   
  45. #include <bsp/irq.h>  
  46.   
  47. RTEMS_BSD_DRIVER_SMC0(0x4e000000,  RVPBXA9_IRQ_ETHERNET);  
  48.   
  49. #elif defined(LIBBSP_ARM_LPC32XX_BSP_H)  
  50.   
  51. #include <bsp/irq.h>  
  52.   
  53. RTEMS_BSD_DRIVER_LPC32XX_PWR;  
  54. RTEMS_BSD_DRIVER_LPC32XX_LPE;  
  55. RTEMS_BSD_DRIVER_ICSPHY;  
  56. RTEMS_BSD_DRIVER_LPC32XX_OHCI;  
  57. SYSINIT_DRIVER_REFERENCE(usbus, ohci);  
  58. RTEMS_BSD_DRIVER_USB;  
  59. RTEMS_BSD_DRIVER_USB_MASS;  
  60.   
  61. #elif defined(LIBBSP_M68K_GENMCF548X_BSP_H)  
  62.   
  63. RTEMS_BSD_DRIVER_FEC;  
  64.   
  65. #elif defined(LIBBSP_ARM_XILINX_ZYNQ_BSP_H)  
  66.   
  67. #include <bsp/irq.h>  
  68.   
  69. RTEMS_BSD_DRIVER_XILINX_ZYNQ_SLCR;  
  70. RTEMS_BSD_DRIVER_XILINX_ZYNQ_CGEM0(ZYNQ_IRQ_ETHERNET_0);  
  71. RTEMS_BSD_DRIVER_E1000PHY;  
  72.   
  73. #elif defined(LIBBSP_ARM_ATSAM_BSP_H)  
  74.   
  75. RTEMS_BSD_DRIVER_USB;  
  76. RTEMS_BSD_DRIVER_USB_MASS;  
  77.   
  78. #elif defined(LIBBSP_ARM_ALTERA_CYCLONE_V_BSP_H)  
  79.   
  80. #include <bsp/socal/hps.h>  
  81. #include <bsp/irq.h>  
  82.   
  83. RTEMS_BSD_DRIVER_DWC0((unsigned long) ALT_EMAC1_ADDR,  
  84.               ALT_INT_INTERRUPT_EMAC1_IRQ);  
  85. RTEMS_BSD_DRIVER_MIPHY;  
  86. RTEMS_BSD_DRIVER_DWCOTG0((unsigned long) ALT_USB1_ADDR,  
  87.              ALT_INT_INTERRUPT_USB1_IRQ);  
  88. RTEMS_BSD_DRIVER_DWC_MMC;  
  89. RTEMS_BSD_DRIVER_MMC;  
  90. RTEMS_BSD_DRIVER_USB;  
  91. RTEMS_BSD_DRIVER_USB_MASS;  
  92.   
  93. #elif defined(LIBBSP_ARM_LPC24XX_BSP_H)  
  94.   
  95. RTEMS_BSD_DEFINE_NEXUS_DEVICE(ohci, 0, 0, NULL);  
  96. SYSINIT_DRIVER_REFERENCE(usbus, ohci);  
  97. RTEMS_BSD_DRIVER_USB;  
  98. RTEMS_BSD_DRIVER_USB_MASS;  
  99.   
  100. #elif defined(LIBBSP_I386_PC386_BSP_H)  
  101.   
  102. RTEMS_BSD_DRIVER_PC_LEGACY;  
  103. RTEMS_BSD_DRIVER_PCI_LEM;  
  104. RTEMS_BSD_DRIVER_PCI_IGB;  
  105. RTEMS_BSD_DRIVER_PCI_EM;  
  106. RTEMS_BSD_DRIVER_PCI_RE;  
  107. RTEMS_BSD_DRIVER_REPHY;  
  108.   
  109. #elif defined(LIBBSP_POWERPC_QORIQ_BSP_H)  
  110.   
  111. #if !QORIQ_CHIP_IS_T_VARIANT(QORIQ_CHIP_VARIANT)  
  112.   
  113. #include <bsp/irq.h>  
  114.   
  115. RTEMS_BSD_DEFINE_NEXUS_DEVICE(ofwbus, 0, 0, NULL);  
  116. SYSINIT_DRIVER_REFERENCE(simplebus, ofwbus);  
  117. SYSINIT_DRIVER_REFERENCE(tsec, simplebus);  
  118. SYSINIT_DRIVER_REFERENCE(ukphy, miibus);  
  119.   
  120. #endif /* !QORIQ_CHIP_IS_T_VARIANT(QORIQ_CHIP_VARIANT) */  
  121.   
  122. #endif  
  123.   
  124. #endif  


As you can see, there is no support for BBB, so you need to add the following fields:

  1. #elif defined(LIBBSP_ARM_BEAGLE_BSP_H)  


Then, to add bus support, FreeBSD's device tree is root_bus, the bus, then nexus mounts on root_bus, then ofwbus mounts on nexus, and then simplebus hangs on ofwbus. Then other uhub or other devices are mounted on the simplebus.


Therefore, the following code needs to be added:

  1. RTEMS_BSD_DEFINE_NEXUS_DEVICE(ofwbus, 0, 0, NULL);  
  2. SYSINIT_DRIVER_REFERENCE(simplebus, ofwbus);  
  3. SYSINIT_DRIVER_REFERENCE(ti_scm, simplebus);  
  4. SYSINIT_DRIVER_REFERENCE(am335x_prcm, simplebus);  
  5. SYSINIT_DRIVER_REFERENCE(usbss, simplebus);  
  6. SYSINIT_DRIVER_REFERENCE(musbotg, usbss);  

The first line indicates that the ofwbus is mounted on the nexus, and the other lines are other mount relationships. This enables FDT support to be implemented at the BSP layer.

In addition, looking at the opt_platform.h file shows that if you need to enable FDT, you should also define the macro BSP_FDT_IS_SUPPORTED.

Therefore, we need to add in the bsp.h of the RTEMS source code:

  1. #define BSP_FDT_IS_SUPPORTED  
That's the way RTEMS-libbsd adds FDT support.


评论

此博客中的热门博文

How to generate image file and dd to SD card

Developed the I2C driver for Beaglebone Black BSP

Compiling RTEMS for Beaglebone Black BSP