You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/12/19 02:51:05 UTC

[GitHub] [incubator-nuttx] Virus-V opened a new pull request #2566: arch/risc-v: Add BL602 support

Virus-V opened a new pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566


   ## Summary
   Add BouffaloLab BL602 support
   
   ## Impact
   Support BL602 SoC, provide UART and Timer driver
   
   ## Testing
   Tested on bl602evb board
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-748409838


   @Virus-V As I mentioned in my first review, the register definitions are not at all in the NuttX style.  I would be happy to convert those for you.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r548342868



##########
File path: arch/risc-v/include/bl602/chip.h
##########
@@ -1,6 +1,9 @@
 /****************************************************************************
  * arch/risc-v/include/bl602/chip.h
  *
+ * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *

Review comment:
       We refer to the format here at first:
   https://cwiki.apache.org/confluence/display/NUTTX/Coding+Standard#cfilestructure
   
   > convert to Apache 2.0 (same for all headers with Greg as sole author)
   Does it mean adding Greg as the sole author?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750698882


   > > Also, @Virus-V, I noticed there's a very brief header for BLE HCI interface. Do you think it is possible to integrate BLE with NuttX using this interface? I understand this is part of closed source libblecontroller.a. Or does this code depend on some other RTOS in some way?
   > 
   > We plan to implement BLE HCI as a pseudo-tty device, and may not use the HCI interface provided by Nuttx (Consulted with BLE colleagues).
   
   You mean as BLE UART?
   
   From what I understand there is a RAM based interface (calls into the closed binary). To proper approach (in line with how NuttX exposes the on-chip BLE controller) is using a bt_driver, which is based on HCI send/receive interface. BL602 BLE should not be based on an ad-hoc driver if there's an option to send/receive HCI commands to the BLE controller.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-751315757


   > > > > @Virus-V can we help getting these hardware headers sorted out so they are inline with NuttX? I think that is the biggest hurdle to getting the initial work merged.
   > > > 
   > > > 
   > > > @btashton Very welcome! To be honest, we have spent a lot of time on formatting the code...  :)
   > > 
   > > Great! I'll see what I can do the next day or so I think we can get it in a good place.
   > 
   > Will you be making a PR against buffalo labs fork? I can also give a hand to work on the PR and test.
   
   Yeah that's my plan. I have all the registers maps added just need to need to update the drivers to use them.  Should have that done tonight or tomorrow.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750347017


   Just received my pinecone so I could make a quick test of the functional part of this PR. Can I flash via JTAG?
   Also, @Virus-V, I noticed there's a very brief header for BLE HCI interface. Do you think it is possible to integrate BLE with NuttX using this interface? I understand this is part of closed source libblecontroller.a. Or does this code depend on something other RTOS in some way?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V edited a comment on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V edited a comment on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750698543


   > @Virus-V can we help getting these hardware headers sorted out so they are inline with NuttX? I think that is the biggest hurdle to getting the initial work merged.
   
   @btashton Very welcome! To be honest, we have spent a lot of time on formatting the code...  :)
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-752016288


   @xiaoxiang781216 Ok I do think we should try to get my changes in soon though as there are still a lot of outstanding issues here that I have addressed.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616844648



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       This added a declaration in system-wide header, which conflicts with arch-dependant definitions (which in some cases as inline). It probably affects other arch's.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r548342868



##########
File path: arch/risc-v/include/bl602/chip.h
##########
@@ -1,6 +1,9 @@
 /****************************************************************************
  * arch/risc-v/include/bl602/chip.h
  *
+ * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *

Review comment:
       We refer to the format here at first:
   https://cwiki.apache.org/confluence/display/NUTTX/Coding+Standard#cfilestructure
   
   > convert to Apache 2.0 (same for all headers with Greg as sole author)
   
   Does it mean adding Greg as the sole author?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-751562561


   @v01d @xiaoxiang781216 @btashton Is there still some work we need to do?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546185504



##########
File path: arch/risc-v/src/bl602/hardware/bl602_common.h
##########
@@ -0,0 +1,231 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/hardware/bl602_common.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_BL602_HARDWARE_BL602_COMMON_H
+#define __ARCH_RISCV_SRC_BL602_HARDWARE_BL602_COMMON_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define BL602_FLASH_XIP_BASE        0x23000000
+#define BL602_FLASH_XIP_END         (0x23000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP0_BASE 0x33000000
+#define BL602_FLASH_XIP_REMAP0_END  (0x33000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP1_BASE 0x43000000
+#define BL602_FLASH_XIP_REMAP1_END  (0x43000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP2_BASE 0x53000000
+#define BL602_FLASH_XIP_REMAP2_END  (0x53000000 + 16 * 1024 * 1024)
+
+#define BL602_WRAM_BASE        0x42020000
+#define BL602_WRAM_END         (0x42020000 + 176 * 1024)
+#define BL602_WRAM_REMAP0_BASE 0x22020000
+#define BL602_WRAM_REMAP0_END  (0x22020000 + 176 * 1024)
+#define BL602_WRAM_REMAP1_BASE 0x32020000
+#define BL602_WRAM_REMAP1_END  (0x32020000 + 176 * 1024)
+#define BL602_WRAM_REMAP2_BASE 0x52020000
+#define BL602_WRAM_REMAP2_END  (0x52020000 + 176 * 1024)
+
+#define BL602_TCM_BASE        0x22008000
+#define BL602_TCM_END         (0x22008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP0_BASE 0x32008000
+#define BL602_TCM_REMAP0_END  (0x32008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP1_BASE 0x42008000
+#define BL602_TCM_REMAP1_END  (0x42008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP2_BASE 0x52008000
+#define BL602_TCM_REMAP2_END  (0x52008000 + (96 + 176) * 1024)
+
+/* BL602 peripherals base address */
+
+#define GLB_BASE ((uint32_t)0x40000000)
+#define RF_BASE  ((uint32_t)0x40001000)
+
+/* AUX module base address */
+
+#define GPIP_BASE ((uint32_t)0x40002000)
+
+/* Security Debug module base address */
+
+#define SEC_DBG_BASE ((uint32_t)0x40003000)
+
+/* Security Engine module base address */
+
+#define SEC_ENG_BASE ((uint32_t)0x40004000)
+
+/* Trustzone control security base address */
+
+#define TZC_SEC_BASE ((uint32_t)0x40005000)
+
+/* Trustzone control none-security base address */
+
+#define TZC_NSEC_BASE ((uint32_t)0x40006000)
+#define EF_DATA_BASE  ((uint32_t)0x40007000)
+#define EF_CTRL_BASE  ((uint32_t)0x40007000)
+#define CCI_BASE      ((uint32_t)0x40008000)
+
+/* L1 cache config base address */
+
+#define L1C_BASE         ((uint32_t)0x40009000)
+#define UART0_BASE       ((uint32_t)0x4000A000)
+#define UART1_BASE       ((uint32_t)0x4000A100)
+#define SPI_BASE         ((uint32_t)0x4000A200)
+#define I2C_BASE         ((uint32_t)0x4000A300)
+#define PWM_BASE         ((uint32_t)0x4000A400)
+#define TIMER_BASE       ((uint32_t)0x4000A500)
+#define IR_BASE          ((uint32_t)0x4000A600)
+#define SF_CTRL_BASE     ((uint32_t)0x4000B000)
+#define SF_CTRL_BUF_BASE ((uint32_t)0x4000B700)
+#define DMA_BASE         ((uint32_t)0x4000C000)
+#define SDU_BASE         ((uint32_t)0x4000D000)
+
+/* Power down sleep module base address */
+
+#define PDS_BASE ((uint32_t)0x4000E000)
+
+/* Hibernate module base address */
+
+#define HBN_BASE ((uint32_t)0x4000F000)
+
+/* Always on module base address */
+
+#define AON_BASE     ((uint32_t)0x4000F000)
+#define HBN_RAM_BASE ((uint32_t)0x40010000)
+
+#define BL_RD_WORD(addr)       (*((volatile uint32_t *)(addr)))
+#define BL_WR_WORD(addr, val)  ((*(volatile uint32_t *)(addr)) = (val))
+#define BL_RD_SHORT(addr)      (*((volatile uint16_t *)(addr)))
+#define BL_WR_SHORT(addr, val) ((*(volatile uint16_t *)(addr)) = (val))
+#define BL_RD_BYTE(addr)       (*((volatile uint8_t *)(addr)))
+#define BL_WR_BYTE(addr, val)  ((*(volatile uint8_t *)(addr)) = (val))
+#define BL_RDWD_FRM_BYTEP(p) \
+  ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0]))
+#define BL_WRWD_TO_BYTEP(p, val) \
+  { \
+    p[0] = val & 0xff; \
+    p[1] = (val >> 8) & 0xff; \
+    p[2] = (val >> 16) & 0xff; \
+    p[3] = (val >> 24) & 0xff; \
+  }
+/**
+ * @brief Register access macro
+ */
+#define BL_RD_REG16(addr, regname) BL_RD_SHORT(addr + regname##_OFFSET)
+#define BL_WR_REG16(addr, regname, val) \
+  BL_WR_SHORT(addr + regname##_OFFSET, val)
+#define BL_RD_REG(addr, regname)      BL_RD_WORD(addr + regname##_OFFSET)
+#define BL_WR_REG(addr, regname, val) BL_WR_WORD(addr + regname##_OFFSET, val)

Review comment:
       registers should already be defined as from a base and an offset into a macro, there shouldn't be a macro to do this as a function




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750922593


   > > > > Also, @Virus-V, I noticed there's a very brief header for BLE HCI interface. Do you think it is possible to integrate BLE with NuttX using this interface? I understand this is part of closed source libblecontroller.a. Or does this code depend on some other RTOS in some way?
   > > > 
   > > > 
   > > > We plan to implement BLE HCI as a pseudo-tty device, and may not use the HCI interface provided by Nuttx (Consulted with BLE colleagues).
   > > 
   > > 
   > > You mean as HCI UART?
   > > From what I understand there is a RAM based interface (calls into the closed binary). To proper approach (in line with how NuttX exposes the on-chip BLE controller) is using a bt_driver, which is based on HCI send/receive interface. BL602 BLE should not be based on an ad-hoc driver if there's an option to send/receive HCI commands to the BLE controller.
   > 
   > We use BLE HCI as a pseudo-tty device because of current requirements, which will make it easy to integrate a third-party BT stack.
   > We will also consider supporting native Nuttx BLE HCI in the future.
   
   Hopefully we can find a way to meet both approaches, based both on Buffalo Labs contributions and NuttX community work. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
davids5 commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616855960



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       I know, very strange, it could be the build setting under PX4 not allowing the warning. But it is fundamentally wrong.  
   
   https://github.com/apache/incubator-nuttx/pull/3580




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546181808



##########
File path: arch/risc-v/src/bl602/bl602_glb.c
##########
@@ -0,0 +1,95 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/bl602_glb.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "hardware/bl602_glb.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: glb_uart_fun_sel
+ *
+ * Description:
+ *   Select UART signal function.
+ *
+ * Input Parameters:
+ *   sig: UART signal
+ *   fun: UART function
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void glb_uart_fun_sel(enum glb_uart_sig_e sig, enum glb_uart_sig_fun_e fun)
+{
+  uint32_t sig_pos = 0;
+  uint32_t tmp_val = 0;
+
+  tmp_val = BL_RD_REG(GLB_BASE, GLB_UART_SIG_SEL_0);
+  sig_pos = (sig * 4);
+
+  /* Clear original val */
+
+  tmp_val = tmp_val & (~(0xf << sig_pos));
+
+  /* Set new value */
+
+  tmp_val = tmp_val | (fun << sig_pos);
+  BL_WR_REG(GLB_BASE, GLB_UART_SIG_SEL_0, tmp_val);
+}
+
+/****************************************************************************
+ * Name: glb_ahb_slave1_reset
+ *
+ * Description:
+ *   Select UART signal function.
+ *
+ * Input Parameters:
+ *   sig: UART signal
+ *   fun: UART function
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void glb_ahb_slave1_reset(enum bl_ahb_slave1_e slave1)
+{
+  uint32_t tmp_val = 0;
+
+  tmp_val = BL_RD_REG(GLB_BASE, GLB_SWRST_CFG1);
+  tmp_val &= (~(1 << slave1));
+  BL_WR_REG(GLB_BASE, GLB_SWRST_CFG1, tmp_val);
+  BL_DRV_DUMMY;

Review comment:
       `BL_DRV_DUMMY` macro should be `BL_DRV_DUMMY()` Why these nop are needed also needs to be documented.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546183153



##########
File path: arch/risc-v/src/bl602/bl602_timerisr.c
##########
@@ -0,0 +1,157 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/bl602_timerisr.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <time.h>
+#include <debug.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/clock.h>
+#include <arch/board/board.h>
+
+#include "riscv_arch.h"
+
+#include "chip.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define TICK_COUNT         (160 * 1000 * 1000 / TICK_PER_SEC)
+#define CLINT_BASE_ADDRESS 0x02000000
+
+#define getreg64(a)    (*(volatile uint64_t *)(a))
+#define putreg64(v, a) (*(volatile uint64_t *)(a) = (v))
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool _b_tick_started = false;
+
+#define MTIMER_HIGH (CLINT_BASE_ADDRESS + 0xBFFC)

Review comment:
       Should be moved to a hardware header file.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546182595



##########
File path: arch/risc-v/src/bl602/bl602_schedulesigaction.c
##########
@@ -0,0 +1,196 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/bl602_schedulesigaction.c

Review comment:
       As mentioned before,  we should be able to use the common version of this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-748764967


   @Virus-V it's better to rebase the PR to the latest master:
   ```
   git remote add apache git@github.com:apache/incubator-nuttx.git
   git fetch apache
   git checkout dev_bl602
   git rebase apache
   git push -f origin dev_bl602
   ```
   to avoid the merge patch in the PR.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546182745



##########
File path: arch/risc-v/src/bl602/bl602_start.c
##########
@@ -0,0 +1,155 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/bl602_init.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdint.h>
+
+#include <nuttx/config.h>
+#include <nuttx/arch.h>
+
+#include <arch/board/board.h>
+
+#include "riscv_internal.h"
+#include "chip.h"
+
+#include "bl602_boot2.h"
+#include "hardware/bl602_hbn.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_FEATURES
+#define showprogress(c) up_lowputc(c)
+#else
+#define showprogress(c)
+#endif
+
+#define PARTITION_BOOT2_RAM_ADDR_ACTIVE (0x42049C00)

Review comment:
       This information should be moved into a header.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r548344059



##########
File path: arch/risc-v/include/bl602/chip.h
##########
@@ -1,6 +1,9 @@
 /****************************************************************************
  * arch/risc-v/include/bl602/chip.h
  *
+ * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *

Review comment:
       New files coming into the project should be Apache licensed (with the header as shown in the wiki page you linked). But as you see the header should not have a copyright line.
   What I mentioned before was that if you are copying an existing file from NuttX which is BSD licensed, you can change the header to Apache if the author listed in the header is Gregory Nutt. Looking at the changes, I think the bl602_oneshot_lowerhalf.h and bl602_oneshot_lowerhalf.c are the only case.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r548345806



##########
File path: arch/risc-v/include/bl602/chip.h
##########
@@ -1,6 +1,9 @@
 /****************************************************************************
  * arch/risc-v/include/bl602/chip.h
  *
+ * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *

Review comment:
       Okay, I understand now. I will check this part of the code again, thanks alot




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-748413117


   I have the Sipeed and the DoIT DT-BL10 boards on hand as well as the BL602EVB on the way so I can do some on hardware testing of this.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546182214



##########
File path: arch/risc-v/src/bl602/bl602_irq_dispatch.c
##########
@@ -0,0 +1,106 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/bl602_irq_dispatch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <assert.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
+#include <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "riscv_arch.h"
+#include "riscv_internal.h"
+
+#include "chip.h"
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+volatile uint32_t *g_current_regs;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * bl602_dispatch_irq
+ ****************************************************************************/
+
+void *bl602_dispatch_irq(uint32_t vector, uint32_t *regs)
+{
+  uint32_t  irq  = vector & 0x3ff; /* E24 [9:0] */
+  uint32_t *mepc = regs;
+
+  /* If current is interrupt */
+
+  if (vector & 0x80000000u)

Review comment:
       There are a lot of unsigned indicators `u` and `U` these are not used in the NuttX style.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d edited a comment on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d edited a comment on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750347017


   Just received my pinecone so I could make a quick test of the functional part of this PR. Can I flash via JTAG?
   Also, @Virus-V, I noticed there's a very brief header for BLE HCI interface. Do you think it is possible to integrate BLE with NuttX using this interface? I understand this is part of closed source libblecontroller.a. Or does this code depend on some other RTOS in some way?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546182940



##########
File path: arch/risc-v/src/bl602/bl602_start.c
##########
@@ -0,0 +1,155 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/bl602_init.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdint.h>
+
+#include <nuttx/config.h>
+#include <nuttx/arch.h>
+
+#include <arch/board/board.h>
+
+#include "riscv_internal.h"
+#include "chip.h"
+
+#include "bl602_boot2.h"
+#include "hardware/bl602_hbn.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_FEATURES
+#define showprogress(c) up_lowputc(c)
+#else
+#define showprogress(c)
+#endif
+
+#define PARTITION_BOOT2_RAM_ADDR_ACTIVE (0x42049C00)
+#define PARTITION_HEADER_BOOT2_RAM_ADDR (0x42049C04)
+#define PARTITION_BOOT2_FLASH_HEADER    (0x42049d14)
+#define PARTITION_BOOT2_FLASH_CONFIG    (0x42049d18)
+#define PARTITION_MAGIC                 (0x54504642)
+#define PARTITION_FW_PART_NAME          "FW"
+#define PARTITION_FW_PART_HEADER_SIZE   (0x1000)
+
+/* TODO use header file from project */
+
+#define FW_XIP_ADDRESS (0x23000000)
+
+#define BL602_IDLESTACK_SIZE (CONFIG_IDLETHREAD_STACKSIZE & ~3)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* g_idle_topstack: _sbss is the start of the BSS region as defined by the
+ * linker script. _ebss lies at the end of the BSS region. The idle task
+ * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE.
+ * The IDLE thread is the thread that the system boots on and, eventually,
+ * becomes the IDLE, do nothing task that runs only when there is nothing
+ * else to run.  The heap continues from there until the end of memory.
+ * g_idle_topstack is a read-only variable the provides this computed
+ * address.
+ */
+
+static uint8_t idle_stack[BL602_IDLESTACK_SIZE];
+
+/* Dont change the name of varaible, since we refer this
+ * boot2_partition_table in linker script
+ */
+
+static struct

Review comment:
       This needs to be updated to follow the style guide, including no unnamed structures.
   http://nuttx.apache.org/docs/latest/contributing/coding_style.html#structures




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616841863



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       I guess we missed this during review. From the looks of it this declaration should only be in arch-dependant header, as it is done for other arch. You can make a PR to remove these and we can see if BL602 still builds or it requires further fix.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750726828


   @Virus-V NuttX already provide a generic driver to adapter tty device(either real or pseduo) to native bluetooth stack:
   https://github.com/apache/incubator-nuttx/blob/master/include/nuttx/wireless/bluetooth/bt_uart_shim.h
   https://github.com/apache/incubator-nuttx/blob/master/drivers/wireless/bluetooth/bt_uart_shim.c
   Simply call bt_uart_shim_getdevice and btuart_register in soc or board initilize routine:
   btuart_register(bt_uart_shim_getdevice("/dev/ttyXXX"));


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616853094



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       Strange I was not seeing it in the patch but now I do. My question is the same though where are you seeing this come up? It's been building cleanly for months.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546185624



##########
File path: arch/risc-v/src/bl602/hardware/bl602_common.h
##########
@@ -0,0 +1,231 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/hardware/bl602_common.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_BL602_HARDWARE_BL602_COMMON_H
+#define __ARCH_RISCV_SRC_BL602_HARDWARE_BL602_COMMON_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define BL602_FLASH_XIP_BASE        0x23000000
+#define BL602_FLASH_XIP_END         (0x23000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP0_BASE 0x33000000
+#define BL602_FLASH_XIP_REMAP0_END  (0x33000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP1_BASE 0x43000000
+#define BL602_FLASH_XIP_REMAP1_END  (0x43000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP2_BASE 0x53000000
+#define BL602_FLASH_XIP_REMAP2_END  (0x53000000 + 16 * 1024 * 1024)
+
+#define BL602_WRAM_BASE        0x42020000
+#define BL602_WRAM_END         (0x42020000 + 176 * 1024)
+#define BL602_WRAM_REMAP0_BASE 0x22020000
+#define BL602_WRAM_REMAP0_END  (0x22020000 + 176 * 1024)
+#define BL602_WRAM_REMAP1_BASE 0x32020000
+#define BL602_WRAM_REMAP1_END  (0x32020000 + 176 * 1024)
+#define BL602_WRAM_REMAP2_BASE 0x52020000
+#define BL602_WRAM_REMAP2_END  (0x52020000 + 176 * 1024)
+
+#define BL602_TCM_BASE        0x22008000
+#define BL602_TCM_END         (0x22008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP0_BASE 0x32008000
+#define BL602_TCM_REMAP0_END  (0x32008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP1_BASE 0x42008000
+#define BL602_TCM_REMAP1_END  (0x42008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP2_BASE 0x52008000
+#define BL602_TCM_REMAP2_END  (0x52008000 + (96 + 176) * 1024)
+
+/* BL602 peripherals base address */
+
+#define GLB_BASE ((uint32_t)0x40000000)
+#define RF_BASE  ((uint32_t)0x40001000)
+
+/* AUX module base address */
+
+#define GPIP_BASE ((uint32_t)0x40002000)
+
+/* Security Debug module base address */
+
+#define SEC_DBG_BASE ((uint32_t)0x40003000)
+
+/* Security Engine module base address */
+
+#define SEC_ENG_BASE ((uint32_t)0x40004000)
+
+/* Trustzone control security base address */
+
+#define TZC_SEC_BASE ((uint32_t)0x40005000)
+
+/* Trustzone control none-security base address */
+
+#define TZC_NSEC_BASE ((uint32_t)0x40006000)
+#define EF_DATA_BASE  ((uint32_t)0x40007000)
+#define EF_CTRL_BASE  ((uint32_t)0x40007000)
+#define CCI_BASE      ((uint32_t)0x40008000)
+
+/* L1 cache config base address */
+
+#define L1C_BASE         ((uint32_t)0x40009000)
+#define UART0_BASE       ((uint32_t)0x4000A000)
+#define UART1_BASE       ((uint32_t)0x4000A100)
+#define SPI_BASE         ((uint32_t)0x4000A200)
+#define I2C_BASE         ((uint32_t)0x4000A300)
+#define PWM_BASE         ((uint32_t)0x4000A400)
+#define TIMER_BASE       ((uint32_t)0x4000A500)
+#define IR_BASE          ((uint32_t)0x4000A600)
+#define SF_CTRL_BASE     ((uint32_t)0x4000B000)
+#define SF_CTRL_BUF_BASE ((uint32_t)0x4000B700)
+#define DMA_BASE         ((uint32_t)0x4000C000)
+#define SDU_BASE         ((uint32_t)0x4000D000)
+
+/* Power down sleep module base address */
+
+#define PDS_BASE ((uint32_t)0x4000E000)
+
+/* Hibernate module base address */
+
+#define HBN_BASE ((uint32_t)0x4000F000)
+
+/* Always on module base address */
+
+#define AON_BASE     ((uint32_t)0x4000F000)
+#define HBN_RAM_BASE ((uint32_t)0x40010000)
+
+#define BL_RD_WORD(addr)       (*((volatile uint32_t *)(addr)))
+#define BL_WR_WORD(addr, val)  ((*(volatile uint32_t *)(addr)) = (val))
+#define BL_RD_SHORT(addr)      (*((volatile uint16_t *)(addr)))
+#define BL_WR_SHORT(addr, val) ((*(volatile uint16_t *)(addr)) = (val))
+#define BL_RD_BYTE(addr)       (*((volatile uint8_t *)(addr)))
+#define BL_WR_BYTE(addr, val)  ((*(volatile uint8_t *)(addr)) = (val))
+#define BL_RDWD_FRM_BYTEP(p) \
+  ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0]))
+#define BL_WRWD_TO_BYTEP(p, val) \
+  { \
+    p[0] = val & 0xff; \
+    p[1] = (val >> 8) & 0xff; \
+    p[2] = (val >> 16) & 0xff; \
+    p[3] = (val >> 24) & 0xff; \
+  }
+/**
+ * @brief Register access macro
+ */
+#define BL_RD_REG16(addr, regname) BL_RD_SHORT(addr + regname##_OFFSET)
+#define BL_WR_REG16(addr, regname, val) \
+  BL_WR_SHORT(addr + regname##_OFFSET, val)
+#define BL_RD_REG(addr, regname)      BL_RD_WORD(addr + regname##_OFFSET)
+#define BL_WR_REG(addr, regname, val) BL_WR_WORD(addr + regname##_OFFSET, val)
+#define BL_SET_REG_BIT(val, bitname)  ((val) | (1U << bitname##_POS))
+#define BL_CLR_REG_BIT(val, bitname)  ((val)&bitname##_UMSK)
+#define BL_GET_REG_BITS_VAL(val, bitname) \
+  (((val)&bitname##_MSK) >> bitname##_POS)
+#define BL_SET_REG_BITS_VAL(val, bitname, bitval) \
+  (((val)&bitname##_UMSK) | ((uint32_t)(bitval) << bitname##_POS))
+#define BL_IS_REG_BIT_SET(val, bitname) \
+  (((val) & (1U << (bitname##_POS))) != 0)

Review comment:
       bit handling should either be done explicitly or via something like modifyreg32 if it will be used to change a register. using macros like this obscures code




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750425914


   @v01d my understanding is that the plan is to expose the HCI interface soon so expect that will just drop in fairly easily. We will have to figure out how we want to handle these blobs. Maybe we can pull them in from the SDK like we so with the ESP IDF. 
   
   @Virus-V can we help getting these hardware headers sorted out so they are inline with NuttX? I think that is the biggest hurdle to getting the initial work merged. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
davids5 commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616836971



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       @btashton @v01d Building against 10.1 the irq.h defines `up_irq_restore` and `up_irq_save` as inlines, but these definition are not
   ```
   nuttx/include/nuttx/arch.h:1386:12: error: conflicting declaration of 'irqstate_t up_irq_save()' with 'C' linkage
    1386 | irqstate_t up_irq_save(void);
         |            ^~~~~~~~~~~
   ```
   
   Should this not have come in?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750719162


   
   
   
   > > > Also, @Virus-V, I noticed there's a very brief header for BLE HCI interface. Do you think it is possible to integrate BLE with NuttX using this interface? I understand this is part of closed source libblecontroller.a. Or does this code depend on some other RTOS in some way?
   > > 
   > > 
   > > We plan to implement BLE HCI as a pseudo-tty device, and may not use the HCI interface provided by Nuttx (Consulted with BLE colleagues).
   > 
   > You mean as HCI UART?
   > 
   > From what I understand there is a RAM based interface (calls into the closed binary). To proper approach (in line with how NuttX exposes the on-chip BLE controller) is using a bt_driver, which is based on HCI send/receive interface. BL602 BLE should not be based on an ad-hoc driver if there's an option to send/receive HCI commands to the BLE controller.
   
   We use BLE HCI as a pseudo-tty device because of current requirements, which will make it easy to integrate a third-party BT stack.  
   We will also consider supporting native Nuttx BLE HCI in the future.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d edited a comment on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d edited a comment on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750698882


   > > Also, @Virus-V, I noticed there's a very brief header for BLE HCI interface. Do you think it is possible to integrate BLE with NuttX using this interface? I understand this is part of closed source libblecontroller.a. Or does this code depend on some other RTOS in some way?
   > 
   > We plan to implement BLE HCI as a pseudo-tty device, and may not use the HCI interface provided by Nuttx (Consulted with BLE colleagues).
   
   You mean as HCI UART?
   
   From what I understand there is a RAM based interface (calls into the closed binary). To proper approach (in line with how NuttX exposes the on-chip BLE controller) is using a bt_driver, which is based on HCI send/receive interface. BL602 BLE should not be based on an ad-hoc driver if there's an option to send/receive HCI commands to the BLE controller.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546185247



##########
File path: arch/risc-v/src/bl602/bl602_entry.S
##########
@@ -0,0 +1,144 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/bl602_entry.S
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <arch/rv32im/irq.h>
+
+	.section .init
+	.globl bl602_start
+	.globl __start
+	.type bl602_start,@function
+
+__start:
+bl602_start:
+	.cfi_startproc
+	.cfi_undefined ra
+  .option push
+  .option norelax
+
+  /*disable IRQ*/
+
+	li t0, MSTATUS_MIE
+	csrc mstatus, t0
+
+	la gp, __global_pointer$
+.option pop
+	la sp, _sp_main
+
+#ifndef RUN_IN_RAM
+	/* Load boot2 partition address */
+
+	la a0, __boot2_pt_addr_src
+	la a1, __boot2_pt_addr_start
+	la a2, __boot2_pt_addr_end
+	bgeu a1, a2, 2f
+
+1:

Review comment:
       use declarative names for labels, so that is easier to understand what is going on




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton merged pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton merged pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r548341199



##########
File path: arch/risc-v/include/bl602/chip.h
##########
@@ -1,6 +1,9 @@
 /****************************************************************************
  * arch/risc-v/include/bl602/chip.h
  *
+ * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *

Review comment:
       Why is this being added? Apache headers do not carry copyright.
   What I mentioned before about headers is that if there are files with BSD license where only Greg is the author, in that case you can change the header to Apache so that we do not grow the number of non Apache files. Sorry if I wasn't clear before.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616843465



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       Sorry I am missing the issue here what are you trying to build. The bl602 configurations build fine. Also all the changes here are in the arch specific files. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750732926


   > > @Virus-V can we help getting these hardware headers sorted out so they are inline with NuttX? I think that is the biggest hurdle to getting the initial work merged.
   > 
   > @btashton Very welcome! To be honest, we have spent a lot of time on formatting the code...  :)
   > 
   > 
   
   Great! I'll see what I can do the next day or so I think we can get it in a good place. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-751566165


   > @v01d @xiaoxiang781216 @btashton Is there still some work we need to do?
   
   @Virus-V I have a fairly large patch on top of this that I am working on right now that I think will get this more in line with the structure / style for inclusion https://github.com/bouffalolab/incubator-nuttx/compare/dev_bl602...btashton:bl602-nxt


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616844648



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       This added a declaration in system-wide header, which conflicts with arch-dependant definitions (which in some cases declares them as inline). It probably affects other arch's.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616853094



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       Strange I was not seeing it in the patch but now I do. My question is the same though we're are you seeing this come up? It's been building cleanly for months.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546183221



##########
File path: arch/risc-v/src/bl602/hardware/bl602_common.h
##########
@@ -0,0 +1,231 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/hardware/bl602_common.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_BL602_HARDWARE_BL602_COMMON_H
+#define __ARCH_RISCV_SRC_BL602_HARDWARE_BL602_COMMON_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define BL602_FLASH_XIP_BASE        0x23000000
+#define BL602_FLASH_XIP_END         (0x23000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP0_BASE 0x33000000
+#define BL602_FLASH_XIP_REMAP0_END  (0x33000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP1_BASE 0x43000000
+#define BL602_FLASH_XIP_REMAP1_END  (0x43000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP2_BASE 0x53000000
+#define BL602_FLASH_XIP_REMAP2_END  (0x53000000 + 16 * 1024 * 1024)
+
+#define BL602_WRAM_BASE        0x42020000
+#define BL602_WRAM_END         (0x42020000 + 176 * 1024)
+#define BL602_WRAM_REMAP0_BASE 0x22020000
+#define BL602_WRAM_REMAP0_END  (0x22020000 + 176 * 1024)
+#define BL602_WRAM_REMAP1_BASE 0x32020000
+#define BL602_WRAM_REMAP1_END  (0x32020000 + 176 * 1024)
+#define BL602_WRAM_REMAP2_BASE 0x52020000
+#define BL602_WRAM_REMAP2_END  (0x52020000 + 176 * 1024)
+
+#define BL602_TCM_BASE        0x22008000
+#define BL602_TCM_END         (0x22008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP0_BASE 0x32008000
+#define BL602_TCM_REMAP0_END  (0x32008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP1_BASE 0x42008000
+#define BL602_TCM_REMAP1_END  (0x42008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP2_BASE 0x52008000
+#define BL602_TCM_REMAP2_END  (0x52008000 + (96 + 176) * 1024)
+
+/* BL602 peripherals base address */
+
+#define GLB_BASE ((uint32_t)0x40000000)

Review comment:
       Type casts should be removed.  These are all expected to be memory addresses.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750698543


   > @Virus-V can we help getting these hardware headers sorted out so they are inline with NuttX? I think that is the biggest hurdle to getting the initial work merged.
   
   Very welcome! To be honest, we have spent a lot of time on formatting the code...  :)
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-752015140


   @btashton yes, let's go ahead.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750698007


   > Just received my pinecone so I could make a quick test of the functional part of this PR. Can I flash via JTAG?
   
   It is support to flash code via JTAG, but the speed is slower than the serial port.
   
   > Also, @Virus-V, I noticed there's a very brief header for BLE HCI interface. Do you think it is possible to integrate BLE with NuttX using this interface? I understand this is part of closed source libblecontroller.a. Or does this code depend on some other RTOS in some way?
   
   We plan to implement BLE HCI as a pseudo-tty device, and may not use the HCI interface provided by Nuttx (Consulted with BLE colleagues).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton edited a comment on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton edited a comment on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-751566165


   > @v01d @xiaoxiang781216 @btashton Is there still some work we need to do?
   
   @Virus-V I have a fairly large patch on top of this that I am working on right now that I think will get this more in line with the structure / style for inclusion https://github.com/bouffalolab/incubator-nuttx/compare/dev_bl602...btashton:bl602-nxt
   
   Note:  My branch does not build yet, I am working through the drivers


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r546185395



##########
File path: arch/risc-v/src/bl602/hardware/bl602_common.h
##########
@@ -0,0 +1,231 @@
+/****************************************************************************
+ * arch/risc-v/src/bl602/hardware/bl602_common.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_BL602_HARDWARE_BL602_COMMON_H
+#define __ARCH_RISCV_SRC_BL602_HARDWARE_BL602_COMMON_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define BL602_FLASH_XIP_BASE        0x23000000
+#define BL602_FLASH_XIP_END         (0x23000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP0_BASE 0x33000000
+#define BL602_FLASH_XIP_REMAP0_END  (0x33000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP1_BASE 0x43000000
+#define BL602_FLASH_XIP_REMAP1_END  (0x43000000 + 16 * 1024 * 1024)
+#define BL602_FLASH_XIP_REMAP2_BASE 0x53000000
+#define BL602_FLASH_XIP_REMAP2_END  (0x53000000 + 16 * 1024 * 1024)
+
+#define BL602_WRAM_BASE        0x42020000
+#define BL602_WRAM_END         (0x42020000 + 176 * 1024)
+#define BL602_WRAM_REMAP0_BASE 0x22020000
+#define BL602_WRAM_REMAP0_END  (0x22020000 + 176 * 1024)
+#define BL602_WRAM_REMAP1_BASE 0x32020000
+#define BL602_WRAM_REMAP1_END  (0x32020000 + 176 * 1024)
+#define BL602_WRAM_REMAP2_BASE 0x52020000
+#define BL602_WRAM_REMAP2_END  (0x52020000 + 176 * 1024)
+
+#define BL602_TCM_BASE        0x22008000
+#define BL602_TCM_END         (0x22008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP0_BASE 0x32008000
+#define BL602_TCM_REMAP0_END  (0x32008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP1_BASE 0x42008000
+#define BL602_TCM_REMAP1_END  (0x42008000 + (96 + 176) * 1024)
+#define BL602_TCM_REMAP2_BASE 0x52008000
+#define BL602_TCM_REMAP2_END  (0x52008000 + (96 + 176) * 1024)
+
+/* BL602 peripherals base address */
+
+#define GLB_BASE ((uint32_t)0x40000000)
+#define RF_BASE  ((uint32_t)0x40001000)
+
+/* AUX module base address */
+
+#define GPIP_BASE ((uint32_t)0x40002000)
+
+/* Security Debug module base address */
+
+#define SEC_DBG_BASE ((uint32_t)0x40003000)
+
+/* Security Engine module base address */
+
+#define SEC_ENG_BASE ((uint32_t)0x40004000)
+
+/* Trustzone control security base address */
+
+#define TZC_SEC_BASE ((uint32_t)0x40005000)
+
+/* Trustzone control none-security base address */
+
+#define TZC_NSEC_BASE ((uint32_t)0x40006000)
+#define EF_DATA_BASE  ((uint32_t)0x40007000)
+#define EF_CTRL_BASE  ((uint32_t)0x40007000)
+#define CCI_BASE      ((uint32_t)0x40008000)
+
+/* L1 cache config base address */
+
+#define L1C_BASE         ((uint32_t)0x40009000)
+#define UART0_BASE       ((uint32_t)0x4000A000)
+#define UART1_BASE       ((uint32_t)0x4000A100)
+#define SPI_BASE         ((uint32_t)0x4000A200)
+#define I2C_BASE         ((uint32_t)0x4000A300)
+#define PWM_BASE         ((uint32_t)0x4000A400)
+#define TIMER_BASE       ((uint32_t)0x4000A500)
+#define IR_BASE          ((uint32_t)0x4000A600)
+#define SF_CTRL_BASE     ((uint32_t)0x4000B000)
+#define SF_CTRL_BUF_BASE ((uint32_t)0x4000B700)
+#define DMA_BASE         ((uint32_t)0x4000C000)
+#define SDU_BASE         ((uint32_t)0x4000D000)
+
+/* Power down sleep module base address */
+
+#define PDS_BASE ((uint32_t)0x4000E000)
+
+/* Hibernate module base address */
+
+#define HBN_BASE ((uint32_t)0x4000F000)
+
+/* Always on module base address */
+
+#define AON_BASE     ((uint32_t)0x4000F000)
+#define HBN_RAM_BASE ((uint32_t)0x40010000)
+
+#define BL_RD_WORD(addr)       (*((volatile uint32_t *)(addr)))
+#define BL_WR_WORD(addr, val)  ((*(volatile uint32_t *)(addr)) = (val))
+#define BL_RD_SHORT(addr)      (*((volatile uint16_t *)(addr)))
+#define BL_WR_SHORT(addr, val) ((*(volatile uint16_t *)(addr)) = (val))
+#define BL_RD_BYTE(addr)       (*((volatile uint8_t *)(addr)))
+#define BL_WR_BYTE(addr, val)  ((*(volatile uint8_t *)(addr)) = (val))

Review comment:
       these are getreg/putreg essentially, should not be defined here




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Virus-V commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
Virus-V commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-752004323


   @btashton Can you consider merging this PR first and use your modification as a new PR? We can review it together.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-750922748


   > > > @Virus-V can we help getting these hardware headers sorted out so they are inline with NuttX? I think that is the biggest hurdle to getting the initial work merged.
   > > 
   > > 
   > > @btashton Very welcome! To be honest, we have spent a lot of time on formatting the code...  :)
   > 
   > Great! I'll see what I can do the next day or so I think we can get it in a good place.
   
   Will you be making a PR against buffalo labs fork? I can also give a hand to work on the PR and test.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
v01d commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r548341199



##########
File path: arch/risc-v/include/bl602/chip.h
##########
@@ -1,6 +1,9 @@
 /****************************************************************************
  * arch/risc-v/include/bl602/chip.h
  *
+ * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *

Review comment:
       Why is this being added? Apache headers do not carry copyright.
   What I mentioned before about headers is that if there are files with BSD license where only Greg is the author, in that case you can change the header to Apache so that we do not grow the number of non Apache files.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#discussion_r616843465



##########
File path: include/nuttx/arch.h
##########
@@ -1353,6 +1354,39 @@ void up_irqinitialize(void);
 
 bool up_interrupt_context(void);
 
+/****************************************************************************
+ * Name: up_irq_save
+ *
+ * Description:
+ *   Save the current interrupt state and disable interrupts.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Interrupt state prior to disabling interrupts.
+ *
+ ****************************************************************************/
+
+irqstate_t up_irq_save(void);
+
+/****************************************************************************
+ * Name: up_irq_restore
+ *
+ * Description:
+ *   Restore the previous irq state (i.e., the one previously
+ *   returned by up_irq_save())
+ *
+ * Input Parameters:
+ *   irqstate - The interrupt state to be restored.
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void up_irq_restore(irqstate_t irqstate);
+

Review comment:
       Sorry I am missing the issue here what are you trying to build. The bl602 configurations build fine.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2566: arch/risc-v: Add BL602 support

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2566:
URL: https://github.com/apache/incubator-nuttx/pull/2566#issuecomment-751915349


   > > @v01d @xiaoxiang781216 @btashton Is there still some work we need to do?
   > 
   > @Virus-V I have a fairly large patch on top of this that I am working on right now that I think will get this more in line with the structure / style for inclusion [bouffalolab/incubator-nuttx@dev_bl602...btashton:bl602-nxt](https://github.com/bouffalolab/incubator-nuttx/compare/dev_bl602...btashton:bl602-nxt)
   > 
   > Note: My branch does not build yet, I am working through the drivers
   
   My branch is now building and my commits squashed, but I am sorting out the flash tools to be able to fully test my changes.  I have the evb so I would expect it to not be too difficult.  I did find a couple bugs, but I may have also introduced some as well.
   
   @xiaoxiang781216 what are your thoughts on moving this forward?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org