Re: macOS Sierra Support

2017-01-10 Thread Peter Snyder
There were two things I needed to do to get GDB to work. You need the latest 
GDB (which it looks like you have) and then codesign the binary. Even though it 
refers to an older version of MacOS, I found the following instructions under 
2.1 in this webpage helpful: https://sourceware.org/gdb/wiki/BuildingOnDarwin 


Also, you need to add this to your ~/.gdbinit file:
set startup-with-shell off

I had issues runniing GDB and these two things solved them. One caveat however, 
apparently quitting GDB leaves zombie process around - these appear benign as 
they aren’t holding any resources, but it is disconcerting.

- peter


> On Jan 10, 2017, at 9:53 AM, David G. Simmons  wrote:
> 
> I'm running the latest Sierra without issue ... 
> DSimmons-Pro:myproj dsimmons$ newt -v build air_q
> Building target targets/air_q
> Loading compiler 
> /Users/dsimmons/dev/myproj/repos/apache-mynewt-core/compiler/arm-none-eabi-m4,
>  def debug
> Compiling src in base directory: 
> /Users/dsimmons/dev/myproj/bin/targets/air_q/generated/src
> Loading compiler 
> /Users/dsimmons/dev/myproj/repos/apache-mynewt-core/compiler/arm-none-eabi-m4,
>  def debug
> Compiling src in base directory: 
> /Users/dsimmons/dev/myproj/apps/air_quality/src
> ...
> DSimmons-Pro:apache-mynewt-core dsimmons$ gdb --version
> GNU gdb (GDB) 7.11.1
> Copyright (C) 2016 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later 
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-apple-darwin15.5.0".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> .
> Find the GDB manual and other documentation resources online at:
> .
> For help, type "help".
> Type "apropos word" to search for commands related to "word".
> DSimmons-Pro:apache-mynewt-core dsimmons$
> 
> 
> MacOS Sierra v10.12.2 (16C67)
> 
> dg
>> On Jan 10, 2017, at 12:45 PM, Sterling Hughes  wrote:
>> 
>> Hi,
>> 
>> On the latest develop with the latest macOS Sierra and homebrew, If I have a 
>> target:
>> 
>> targets/slim_slinky
>>   app=apps/slinky
>>   bsp=hw/bsp/native
>>   build_profile=debug
>> 
>> (used to be optimized :-)
>> 
>> And I try and build:
>> 
>> $ newt run slim_slinky
>> Error: In file included from 
>> /usr/local/Cellar/gcc5/5.4.0/lib/gcc/5/gcc/x86_64-apple-darwin15.0.0/5.4.0/include-fixed/syslimits.h:7:0,
>>from 
>> /usr/local/Cellar/gcc5/5.4.0/lib/gcc/5/gcc/x86_64-apple-darwin15.0.0/5.4.0/include-fixed/limits.h:34,
>>from encoding/tinycbor/include/tinycbor/cbor.h:29,
>>from mgmt/newtmgr/include/newtmgr/newtmgr.h:23,
>>from apps/slinky/src/main.c:37:
>> /usr/local/Cellar/gcc5/5.4.0/lib/gcc/5/gcc/x86_64-apple-darwin15.0.0/5.4.0/include-fixed/limits.h:168:61:
>>  error: no include path in which to search for limits.h
>> 
>> I get beyond this by compiling out gcc-5, and instead using the native Mac 
>> LLVM compiler (fixes in dev to make the system work with that).  However, 
>> the next issue is gdb:
>> 
>> $ newt run slim_slinky
>> 
>> [/Users/sterling/dev/mynewt/core/hw/bsp/native/native_debug.sh 
>> /Users/sterling/dev/mynewt/core/hw/bsp/native 
>> /Users/sterling/dev/mynewt/core/bin/targets/slim_slinky/app/apps/slinky/slinky]
>> Debugging 
>> /Users/sterling/dev/mynewt/core/bin/targets/slim_slinky/app/apps/slinky/slinky.elf
>> 
>> Reading symbols from 
>> /Users/sterling/dev/mynewt/core/bin/targets/slim_slinky/app/apps/slinky/slinky.elf...done.
>> (gdb) c
>> The program is not being run.
>> (gdb) r
>> Starting program: 
>> /Users/sterling/dev/mynewt/core/bin/targets/slim_slinky/app/apps/slinky/slinky.elf
>> During startup program terminated with signal ?, Unknown signal.
>> (gdb)
>> 
>> If I switch to using llvm debugger, I can debug the system.  Which is fine, 
>> but I do generally prefer gdb due to familiarity.  Still, for those 
>> searching for a quick solution, lldb is fine.
>> 
>> Has anyone had success making these work on the latest macOS sierra.  My 
>> toolchain information:
>> 
>> $ gdb --version
>> GNU gdb (GDB) 7.12
>> Copyright (C) 2016 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later 
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-apple-darwin15.6.0".
>> $ gcc-5 --version
>> gcc-5 (Homebrew gcc5 5.4.0) 5.4.0
>> Copyright (C) 2015 Free Software Foundation, Inc.
>> This is free software; see the source for copying conditions.  

Re: NFFS compile error

2017-01-03 Thread Peter Snyder
Hi Cris,

There have been a number of changes in the 1.0-b1 release in how mynewt is 
initialized and the documentation hasn’t quite caught up yet. The kernel now 
initializes the packages that are specified in pkg.yml automatically as part of 
system start up, and that includes the nffs filesystem init code in your main.c.

Your syscfg.yml and pkg.yml files look okay. To be specific, you can remove the 
following lines from your code:

> /* NFFS_AREA_MAX is defined in the BSP-specified bsp.h header file. */
>struct nffs_area_desc descs[NFFS_AREA_MAX];
> 
>/* Initialize nffs's internal state. */
>rc = nffs_init();
> 
> 
>assert(rc == 0);
> 
>/* Convert the set of flash blocks we intend to use for nffs into an array
> * of nffs area descriptors.
> */
>cnt = NFFS_AREA_MAX;
>rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, , descs);
>assert(rc == 0);
> 
>/* Attempt to restore an existing nffs file system from flash. */
>if (nffs_detect(descs) == FS_ECORRUPT) {
>/* No valid nffs instance detected; format a new one. */
>rc = nffs_format(descs);
>assert(rc == 0);
>}

Hope this helps.

- peter


> On Jan 2, 2017, at 9:12 PM, Cris Frusina  wrote:
> 
> Hi All,
> 
> I'm trying to get NFFS working in my project but I'm not having any luck.
> 
> The *BSP* *syscfg.yml* file has this included:
> 
> syscfg.vals:
>CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS
>REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG
>NFFS_FLASH_AREA: FLASH_AREA_NFFS
>COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1
> 
> The *bsp.yml:*
> 
> bsp.flash_map:
>areas:
># System areas.
>FLASH_AREA_BOOTLOADER:
>device: 0
>offset: 0x
>size: 16kB
>FLASH_AREA_IMAGE_0:
>device: 0
>offset: 0x8000
>size: 232kB
>FLASH_AREA_IMAGE_1:
>device: 0
>offset: 0x00042000
>size: 232kB
>FLASH_AREA_IMAGE_SCRATCH:
>device: 0
>offset: 0x0007c000
>size: 4kB
> 
># User areas.
>FLASH_AREA_REBOOT_LOG:
>user_id: 0
>device: 0
>offset: 0x4000
>size: 16kB
>FLASH_AREA_NFFS:
>user_id: 1
>device: 0
>offset: 0x0007d000
>size: 12kB
> 
> *APP **syscfg.yml* has this line:
> 
>CONFIG_NFFS: 1
> 
> *APP **pkg.yml:*
> 
> pkg.deps.CONFIG_NFFS:
>- "@apache-mynewt-core/fs/nffs"
> 
> 
> In my main.c I have included the headers and added the sample code to 
> initialize NFFS :
> 
> #include "nffs/nffs.h"
> #include "fs/fs.h"
> 
> 
> /* NFFS_AREA_MAX is defined in the BSP-specified bsp.h header file. */
>struct nffs_area_desc descs[NFFS_AREA_MAX];
> 
>/* Initialize nffs's internal state. */
>rc = nffs_init();
> 
> 
>assert(rc == 0);
> 
>/* Convert the set of flash blocks we intend to use for nffs into an array
> * of nffs area descriptors.
> */
>cnt = NFFS_AREA_MAX;
>rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, , descs);
>assert(rc == 0);
> 
>/* Attempt to restore an existing nffs file system from flash. */
>if (nffs_detect(descs) == FS_ECORRUPT) {
>/* No valid nffs instance detected; format a new one. */
>rc = nffs_format(descs);
>assert(rc == 0);
>}
> 
> 
>rc = fsutil_write_file("/test", "255", 3);
>if (rc != 0) {
> 
>}
> 
> 
> I'm getting this compile error:
> 
> *Compiling main.c**
> **Error: main.c: In function 'main':**
> **main.c:392:5: error: implicit declaration of function 
> 'flash_area_to_nffs_desc' [-Werror=implicit-function-declaration]**
> ** rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, , descs);**
> ** ^**
> **main.c:392:34: error: 'FLASH_AREA_NFFS' undeclared (first use in this 
> function)**
> ** rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, , descs);**
> **  ^**
> **main.c:392:34: note: each undeclared identifier is reported only once for 
> each function it appears in**
> **main.c:403:2: error: implicit declaration of function 'fsutil_write_file' 
> [-Werror=implicit-function-declaration]**
> **  rc = fsutil_write_file("/color", "255", 3);**
> **  ^**
> **cc1: all warnings being treated as errors*
> 
> 
> I did a search for "flash_area_to_nffs_desc" and I can't find a declaration 
> for it anywhere in the repo.
> 
> Anyone have any ideas on why I'm getting these compile errors?
> 
> Thanks,
> 
> Cris
> 
> 
> 



Re: [VOTE] Release Apache Mynewt 1.0.0-b1-incubating-rc2

2016-11-30 Thread Peter Snyder
+1

> On Nov 30, 2016, at 8:31 AM, Vipul Rahane  wrote:
> 
> +1 (binding)
> 
>> On Nov 30, 2016, at 7:09 PM, David G. Simmons  wrote:
>> 
>> +1
>> 
>>> On Nov 29, 2016, at 9:30 PM, Christopher Collins  
>>> wrote:
>>> 
>>> [ ] +1 Release this package
>>> [ ]  0 I don't feel strongly about it, but don't object
>>> [ ] -1 Do not release this package because...
>> 
>> --
>> David G. Simmons
>> (919) 534-5099
>> Web  • Blog  • 
>> Linkedin  • Twitter 
>>  • GitHub 
>> /** Message digitally signed for security and authenticity.  
>> * If you cannot read the PGP.sig attachment, please go to 
>> * http://www.gnupg.com/  Secure your email!!!
>> * Public key available at keyserver.pgp.com 
>> **/
>> ♺ This email uses 100% recycled electrons. Don't blow it by printing!
>> 
>> There are only 2 hard things in computer science: Cache invalidation, naming 
>> things, and off-by-one errors.
>> 
>> 
> 



Re: [DISCUSS] Proposed changes to mynewt website

2016-11-04 Thread Peter Snyder
The changes look good to me too. Just a suggestion, for the “Security from the 
Start” section, perhaps a diagram that illustrates the product lifecycle, i.e., 
from development through deployment. That being said, I’m not sure how to show 
that the support is built in to the ecosystem - I think showing the included 
security algorithms is good, but perhaps something different than the section 
of a header file.

-peter

> On Nov 4, 2016, at 1:55 PM, Sterling Hughes  wrote:
> 
> 
>> Got it - about the tech docs release. How about the website changes? I was 
>> proposing we merge that into master for beta.
>> 
> 
> +1 from me, they look great.
> 
> Sterling



Re: Adding C++ header guards?

2016-09-11 Thread Peter Snyder
I think this is great too, but I don’t think it’s keeping to the mynewt coding 
standard. In particular I think the C++ wrappers are supposed to appear after 
other included files and before any file content. For sure this messes up your 
script (sorry) but it avoids any potential conflicts with the included headers. 
I’m fine being corrected on this (sure would be easier to automate this work 
:-).

Here’s the relevant section from the coding standard 
:
Header files must contain the following structure:

Apache License (see above)
#ifdef aliasing, to prevent multiple includes
#include directives for other required header files
#ifdef __cplusplus wrappers to maintain C++ friendly APIs
Contents of the header file
- peter


> On Sep 11, 2016, at 12:41 PM, Christopher Collins  wrote:
> 
> On Sun, Sep 11, 2016 at 12:39:27PM -0700, Christopher Collins wrote:
>> Look great to me, thanks!  I just have a question - the commit message
>> indicates that two files were not modified:
>> 
>>libs/baselibc/src/baselibc_test/unittests.h
>>libs/shell/include/shell/shell_prompt.h
>> 
>> Why did you exclude these files?
> 
> Er... the commit message also explains why they were excluded [*].
> Sorry :).
> 
> [*] "Because the hack I used looks for normal #include guards for its place
> to put the C++ ones, and those files don't have any."



Heads up on a new toolchain change on a Mac

2016-08-22 Thread Peter Snyder
Hi there,

I just got a new MacBook and needed to install the Mynewt toolchain. The native 
gcc version installed by brew has recently changed requiring that a yml 
configuration file in the newt source tree be changed as well as reporting some 
minor compilation errors that cause sim (native mac) builds to fail. This only 
affects new toolchain installs, there are no issues with existing installs.

Read further if you need to (re)install the mynewt toolchain on a mac.
—

The instructions on the Installing Native Mynewt Tools 
 page 
succeed but install gcc version 6.1 rather the expected 5.x:

==> Using the sandbox
==> Downloading https://ftpmirror.gnu.org/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2
… [snip]…
==> Summary
  /usr/local/Cellar/gcc/6.1.0_1: 1,435 files, 282.3M, built in 30 minutes 44 
seconds

This doesn’t impact cross-compilation, but native compilation (i.e. for the sim 
environment) fails, i.e.:

% newt test all
Testing package @apache-mynewt-core/libs/os
sh: /usr/local/bin/gcc-5: No such file or directory
Testing package @apache-mynewt-core/sys/log
sh: /usr/local/bin/gcc-5: No such file or directory
…

This can be fixed by modifying
/repos/apache-mynewt-core/compiler/sim/compiler.yml
with this change:

42,43c42,43
< compiler.path.cc.DARWIN.OVERWRITE: "/usr/local/bin/gcc-5"
< compiler.path.as.DARWIN.OVERWRITE: "/usr/local/bin/gcc-5 -x 
assembler-with-cpp"
---
> compiler.path.cc.DARWIN.OVERWRITE: "/usr/local/bin/gcc-6"
> compiler.path.as.DARWIN.OVERWRITE: "/usr/local/bin/gcc-6 -x 
> assembler-with-cpp”

The new gcc reports some new minor compilation errors, e.g,

Compiling x509_crl.c
x509_crl.c: In function 'mbedtls_x509_crl_parse':
x509_crl.c:508:5: error: this 'else' clause does not guard... 
[-Werror=misleading-indentation]
 else
 ^~~~
x509_crl.c:514:9: note: ...this statement, but the latter is misleadingly 
indented as if it is guarded by the 'else'
 if( ret == 0 )
 ^~

Tickets will be filed shortly to fix the compile and change the documentation 
accordingly.

- peter