Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library has issues to compile for PCA10059 on Linux, needed fixes linked #23

Open
mame82 opened this issue Jul 27, 2022 · 2 comments
Open

Comments

@mame82
Copy link

mame82 commented Jul 27, 2022

Compilation for all sketches fails on KALI/Debian Linux.

Issues:

  1. Incompatible atomic declaration in HardwarePWN.h
  2. Missing utoa() declaration/definition

Diff to make things work (no PR, as I just copied over iota.c/.hfrom Adafruit repo, without further adjustments):

diff --git a/cores/nRF5/HardwarePWM.h b/cores/nRF5/HardwarePWM.h
index 47ec16c..f3ecbb3 100644
--- a/cores/nRF5/HardwarePWM.h
+++ b/cores/nRF5/HardwarePWM.h
@@ -51,7 +51,7 @@ class HardwarePWM
   private:
     enum { MAX_CHANNELS = 4 }; // Max channel per group
     NRF_PWM_Type * const _pwm;
-    std::atomic_uint32_t _owner_token;
+    std::atomic<uint32_t> _owner_token;
 
     uint16_t _seq0[MAX_CHANNELS];
 
diff --git a/cores/nRF5/itoa.c b/cores/nRF5/itoa.c
index 608145e..49aca53 100644
--- a/cores/nRF5/itoa.c
+++ b/cores/nRF5/itoa.c
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2014 Arduino LLC.  All right reserved.
+  Copyright (c) 2016 Arduino.  All right reserved.
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -8,7 +8,7 @@
 
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
   See the GNU Lesser General Public License for more details.
 
   You should have received a copy of the GNU Lesser General Public
@@ -20,8 +20,56 @@
 #include <string.h>
 
 #ifdef __cplusplus
-extern "C" {
-#endif
+extern "C"{
+#endif // __cplusplus
+
+#if 0
+/* reverse:  reverse string s in place */
+static void reverse( char s[] )
+{
+  int i, j ;
+  char c ;
+
+  for ( i = 0, j = strlen(s)-1 ; i < j ; i++, j-- )
+  {
+    c = s[i] ;
+    s[i] = s[j] ;
+    s[j] = c ;
+  }
+}
+
+/* itoa:  convert n to characters in s */
+extern void itoa( int n, char s[] )
+{
+  int i, sign ;
+
+  if ( (sign = n) < 0 )  /* record sign */
+  {
+    n = -n;          /* make n positive */
+  }
+
+  i = 0;
+  do
+  {       /* generate digits in reverse order */
+    s[i++] = n % 10 + '0';   /* get next digit */
+  } while ((n /= 10) > 0) ;     /* delete it */
+
+  if (sign < 0 )
+  {
+    s[i++] = '-';
+  }
+
+  s[i] = '\0';
+
+  reverse( s ) ;
+}
+
+#else
+
+extern char* itoa( int value, char *string, int radix )
+{
+  return ltoa( value, string, radix ) ;
+}
 
 extern char* ltoa( long value, char *string, int radix )
 {
@@ -73,6 +121,11 @@ extern char* ltoa( long value, char *string, int radix )
   return string;
 }
 
+extern char* utoa( unsigned long value, char *string, int radix )
+{
+  return ultoa( value, string, radix ) ;
+}
+
 extern char* ultoa( unsigned long value, char *string, int radix )
 {
   char tmp[33];
@@ -90,7 +143,7 @@ extern char* ultoa( unsigned long value, char *string, int radix )
   {
     return 0;
   }
-
+ 
   while (v || tp == tmp)
   {
     i = v % radix;
@@ -103,14 +156,15 @@ extern char* ultoa( unsigned long value, char *string, int radix )
 
   sp = string;
 
-
+ 
   while (tp > tmp)
     *sp++ = *--tp;
   *sp = 0;
 
   return string;
 }
+#endif /* 0 */
 
 #ifdef __cplusplus
 } // extern "C"
-#endif
+#endif // __cplusplus
diff --git a/cores/nRF5/itoa.h b/cores/nRF5/itoa.h
index ba0010a..a0cb31d 100644
--- a/cores/nRF5/itoa.h
+++ b/cores/nRF5/itoa.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2015 Arduino LLC.  All right reserved.
+  Copyright (c) 2016 Arduino.  All right reserved.
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -8,7 +8,7 @@
 
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
   See the GNU Lesser General Public License for more details.
 
   You should have received a copy of the GNU Lesser General Public
@@ -16,15 +16,27 @@
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
-#pragma once
+#ifndef _ITOA_
+#define _ITOA_
 
 #ifdef __cplusplus
 extern "C"{
-#endif
+#endif // __cplusplus
 
+#if 0
+
+extern void itoa( int n, char s[] ) ;
+
+#else
+
+extern char* itoa( int value, char *string, int radix ) ;
 extern char* ltoa( long value, char *string, int radix ) ;
+extern char* utoa( unsigned long value, char *string, int radix ) ;
 extern char* ultoa( unsigned long value, char *string, int radix ) ;
+#endif /* 0 */
 
 #ifdef __cplusplus
 } // extern "C"
-#endif
+#endif // __cplusplus
+
+#endif // _ITOA_
@mame82
Copy link
Author

mame82 commented Jul 27, 2022

Some additional infos on flashing PCA10059 Arduino bootloader (Twitter thread, usage of cheap IBDAP CMSIS-DAP with OpenOCD instead of J-LINK debugger):

https://threadreaderapp.com/thread/1552233889867120641.html

@mame82
Copy link
Author

mame82 commented Jul 27, 2022

Cross reference to corresponding issue Adafruit-repo adafruit/Adafruit_nRF52_Arduino#200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant