apache / mynewt-newt

An OS to build, deploy and securely manage billions of devices
https://mynewt.apache.org/
Apache License 2.0
117 stars 96 forks source link

Fix for @repo targets in mfg create #391

Open dwld opened 4 years ago

dwld commented 4 years ago

Without the fix, mfg create for targets such as target.app: "@mcuboot/boot/mynewt" fails, since the path to the .manifest, .hex and .bin is wrong.

This can be fixed by using the target app's FullName() instead of Name().

utzig commented 4 years ago

This use of Name() in those functions has been like this for basically ever. All my MCUBoot targets look something like the one you mentioned (target.app: "@mcuboot/boot/mynewt") and I see no build issues, what errors exactly am I expected to see? Please copy some newt -ldebug ... output here.

dwld commented 4 years ago

Hi @utzig, thanks for your feedback. I'll gather the debug output. Perhaps my .mfg file or my targets are not correct. I just published a documentation update idea, could you perhaps check it? https://github.com/apache/mynewt-newt/pull/392 Thanks.

dwld commented 4 years ago

@utzig, here is the output of the current master newt build as it is:

$ newt -ldebug mfg create p_nrf52_ble 0.0.0.5
...
2020/04/01 16:30:41.371 [DEBUG] goroutine 1 [running]:
mynewt.apache.org/newt/util.NewNewtError(0xc0005a1760, 0xa3, 0xc00007f190)
        C:/<removed_for_privacy_reasons>/Github/mynewt-newt/util/util.go:77 +0xd3
mynewt.apache.org/newt/util.FmtNewtError(0x84555a, 0x2, 0xc00007f190, 0x1, 0x1, 0x0)
        C:/<removed_for_privacy_reasons>/Github/mynewt-newt/util/util.go:84 +0x72
mynewt.apache.org/newt/newt/mfg.newMfgBuildTarget(0xc000150840, 0x12, 0xc000150de0, 0x15, 0x0, 0x0, 0xc00067e210, 0x0, 0x0, 0x0, ...)
        C:/<removed_for_privacy_reasons>/Github/mynewt-newt/newt/mfg/build.go:226 +0x59e
mynewt.apache.org/newt/newt/mfg.newMfgBuilder(0xc0000c26e0, 0xc00043a120, 0x2, 0x2, 0x0, 0x0, 0x0, 0xc00059d170, 0x0, 0x0, ...)
        C:/<removed_for_privacy_reasons>/Github/mynewt-newt/newt/mfg/build.go:439 +0x255
mynewt.apache.org/newt/newt/mfg.LoadMfgEmitter(0xc0000c26e0, 0x500000000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        C:/<removed_for_privacy_reasons>/Github/mynewt-newt/newt/mfg/misc.go:54 +0x15b
mynewt.apache.org/newt/newt/cli.mfgCreateRunCmd(0xc0000eec80, 0xc000108210, 0x2, 0x3)
        C:/<removed_for_privacy_reasons>/Github/mynewt-newt/newt/cli/mfg_cmds.go:117 +0x1ba
github.com/spf13/cobra.(*Command).execute(0xc0000eec80, 0xc0001080f0, 0x3, 0x3, 0xc0000eec80, 0xc0001080f0)
        C:/<removed_for_privacy_reasons>/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830 +0x2b1
github.com/spf13/cobra.(*Command).ExecuteC(0xc00008cf00, 0x845c6b, 0x4, 0x7)
        C:/<removed_for_privacy_reasons>/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x302
github.com/spf13/cobra.(*Command).Execute(...)
        C:/<removed_for_privacy_reasons>/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
main.main()
        C:/<removed_for_privacy_reasons>/Github/mynewt-newt/newt/newt.go:180 +0x19e

goroutine 6 [syscall]:
os/signal.signal_recv(0x0)
        C:/Anwendungen/Go/src/runtime/sigqueue.go:147 +0xa3
os/signal.loop()
        C:/Anwendungen/Go/src/os/signal/signal_unix.go:23 +0x29
created by os/signal.init.0
        C:/Anwendungen/Go/src/os/signal/signal_unix.go:29 +0x48

Error: failed to read manifest file: open C:/Entwicklung/newt_ble_central/bin/targets/nrf52_boot/app/boot/mynewt/manifest.json: The system cannot find the path specified.

With the fix, the command works for me and outputs the following paths as its inputs:

$ newt -ldebug mfg create p_nrf52_ble 0.0.0.5
...
Creating a manufacturing image from the following files:
    C:/Entwicklung/newt_ble_central/bin/targets/nrf52_ble/app/apps/<removed_for_privacy_reasons>/manifest.json
    C:/Entwicklung/newt_ble_central/bin/targets/nrf52_ble/app/apps/<removed_for_privacy_reasons>.elf
    C:/Entwicklung/newt_ble_central/bin/targets/nrf52_ble/app/apps/<removed_for_privacy_reasons>.img
    C:/Entwicklung/newt_ble_central/bin/targets/nrf52_boot/app/@mcuboot/boot/mynewt/manifest.json
    C:/Entwicklung/newt_ble_central/bin/targets/nrf52_boot/app/@mcuboot/boot/mynewt/mynewt.elf
    C:/Entwicklung/newt_ble_central/bin/targets/nrf52_boot/app/@mcuboot/boot/mynewt/mynewt.elf.bin

The nrf52_boot target.yml looks like this:

target.app: "@mcuboot/boot/mynewt"
target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10056"
target.build_profile: optimized

The mfg.yml looks like this:

mfb.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10056"

mfg.targets:
    - nrf52_boot:
      name: "targets/nrf52_boot"
      offset: 0x0
      area: FLASH_AREA_BOOTLOADER
    - nrf52_ble:
      name: "targets/nrf52_ble"
      offset: 0x0
      area: FLASH_AREA_IMAGE_0
mfg.meta:
    area: FLASH_AREA_BOOTLOADER
ccollins476ad commented 4 years ago

@dwld I wonder if this could be a Windows-specific issue you are seeing. Do you think you could show an example without redacting any paths? Unfortunately I don't have a Windows machine available to test this on.

dwld commented 4 years ago

@dwld I wonder if this could be a Windows-specific issue you are seeing. Do you think you could show an example without redacting any paths? Unfortunately I don't have a Windows machine available to test this on.

Sorry for the delay. I was on parental leave and will create new logs with full paths in the next days.